开发者

how to toggle addClass and removeClass?

my code:

<a href=# onclick="obj.addClass开发者_C百科('fliph'); return false;">toggle</a>

i want click toggle to obj.addClass('fliph'),then click again run obj.removeClass('fliph').

how to fix my code?

thanks all! :)


Do it unobtrusive, whereever possible.

<a href=# class="fliph">toggle</a>

Javascript:

$(document).ready(function(){
   $('.fliph').click(function(){
       $(this).toggleClass('fliph');
   });
});


Do you mean this?

<a href=# onclick="obj.toggleClass('fliph'); return false;">toggle</a>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜