开发者

Set class on a tag after click

I have the following code. I wonna set a css class on the a tag that is clicked. But i wonna do it only in the language div. How can i do that? When i try to do it with $("language a") is doesn't do anything.

<div id="wrapper">
 &l开发者_JAVA百科t;div id="language">
    <a href="#" class="">test 1</a>
    <a href="#" class="">test 2</a>
 </div>
    <a href="#" class="">No div 1</a>
    <a href="#" class="">No div 2</a>
</div>

$("a").click(function(event){
   $("a.active").removeClass("active");
   $(this).addClass("active");
});

.active {font-weight: bold; }


$( "#language a" ).click( function() {
    $( "#language a.active" ).removeClass( "active" );
    $( this ).addClass( "active" );
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜