Swap Class of Element
I have the following code:
<a href="#" class="more">text</a>
How can I toggle the class between "more" and "less" when clicked?
$('a').click(function (e) {
e.preventDefault();
var $this = $(this);
$this.toggleClass('more', 'less');
});
But I get the class changing from "more" to "" and not to less.
Thank You, Miguel
No comments:
Post a Comment