I have this code that changes the url every time a user clicks a button in the page.
That works great in safari,chrome,firefox but not in IE 7,8,9.
What could be the problem ?
function setNewNavigationUrls(){
var musicParameter;
if (isMusicOn) {
musicParameter='1';
}else{
musicParameter='0';
}
$("a[href='/']").attr('href', '/?music='+musicParameter);
$("a[href='/collection-glamour-feeling']").attr('href', '/collection-glamour-feeling?music='+musicParameter);
$("a[href='/collection-poetic-moments']").attr('href','/collection-poetic-moments?music='+musicParameter);
$("a[href='/about.html']").attr('href','/about.html?music='+musicParameter);
$("a[href='/contact.html']").attr('href', '/contact.html?music='+musicParameter);
}
Thanks
Shani
You probably should be using “.prop()” instead of “.attr()” to set the “href” of your
<a>elements.With jQuery 1.6, the semantics of “attr()” changed considerably. The “href” attribute becomes a property of the DOM node for the element, and therefore it should be set as a property. The “attr()” method now concerns itself with attributes (via “setAttribute()” and “getAttribute()”). Boolean properties like “checked” and “disabled” are treated in a backwards-compatible fashion following jQuery 1.6.1.