I'm trying to change the middle part of the URL when the proper radio button is clicked.
我正在尝试在单击正确的单选按钮时更改URL的中间部分。
In the three purchase links each one represents an amount. I'm going to be selecting an animal then clicking on 1 of 3 amounts I want to spend. How would I change part of all 3 of the URLs?
There is no middle part, use regular expressions, to cut the string and use the one you want. Changing it is quite easy:
没有中间部分,使用正则表达式来剪切字符串并使用您想要的字符串。改变它很容易:
var edBTN = getElementById('editBTN');
edBTN.setAttribute('href', mynewurl);
#4
0
with jquery or another dom parsing library this should be possible.
使用jquery或其他dom解析库这应该是可能的。
if ( /* radio selected */ ) {
// Go get your src attrib
var src = jQuery( 'selectorforanchortag' ).attr('src');
// Manipulate the src however you need using Javascript string methods
src = src.blergetyblerg();
// Put your new src back where orig was
jQuery( 'selectorforanchortag' ).attr('src');
}