I have a link whose href attribute should be changed based upon the radio button option selected. Here is the link to the code
I see that the href attribute is changed via firebug, but when clicked upon, it does not go to the new link. What could be the issue here?
The HTML:
<a id="urlTest" title="Checkout" href="yahoo.com">Checkout</a>
<p><input type="radio" value="www.apple.com" name="url">Change to apple</p>
<p><input type="radio" value="www.google.com" name="url">Change to google</p>
The JavaScript
$(document).ready(function(){
$('input[name=url]').bind('click', function () {
$("#urlTest").attr("href",$(this).val());
}
});
Your JavaScript is invalid; you’re missing a closing parenthesis at the end of the
bindparameter list. Errors like this are visible in the console (including on jsfiddle).The domain names should be fully-qualified, too.