jQuery: Cannot change style of element after selected
Posted
by JamesBrownIsDead
on Stack Overflow
See other posts from Stack Overflow
or by JamesBrownIsDead
Published on 2010-05-04T01:40:23Z
Indexed on
2010/05/04
1:48 UTC
Read the original article
Hit count: 398
Here is my code. Where you see "alert([...]);", an alert pops up. Why doesn't the CSS style change? The 'click' event fires, too!
resolveSideMenuAddress: function () {
var firstLink = $("#masterHeaderMenu .masterHeaderMenuButton a:first");
function select(link) {
alert('i alert');
link.css({
'color': '#9a4d9e',
'cursor': 'default'
});
alert('color and cursor not changed');
link.click(function () {
alert('click');
return false;
});
}
if (window.location.pathname === firstLink.attr('href')) {
alert('i alert');
select(firstLink);
}
}
I've tried addClass() and can't change the color of the link that way either.
© Stack Overflow or respective owner