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>
精彩评论