changing the color of a link
I want to change the accordion based on clicking a link .It is working fine.The demo is shown in the following link http://jsfiddle.net/kufi/qp5Mg/
Now,I want to change the color of link that clicked(here from red to green).If I click a link it is changing from red to green .If i Click second link the first link remains in green on开发者_Go百科ly,It should be changed to red.
Thanks in advance
$(".accordion-opener").click(function(e) {
$(".accordion-opener").removeClass('green');
$(this).addClass('green');
e.preventDefault();
});
Make use of the addClass
and removeClass
, Demo:
http://jsfiddle.net/qp5Mg/2/
You should add:
<style>
.clicked{
color: green;
}
</style>
And, in js:
$(".accordion-opener").click(function(){
...
$(this).addClass("clicked");
});
EDIT: I've updated your fiddle with this code and is working OK: http://jsfiddle.net/qp5Mg/6/
Hope this helps. Cheers
精彩评论