Comments on: .addClass() http://api.jquery.com/addClass/ jQuery API Reference Mon, 04 Jul 2011 09:02:46 +0000 hourly 1 http://wordpress.org/?v=3.2 By: Ash Singh http://api.jquery.com/addClass/comment-page-1/#comment-8663 Ash Singh Thu, 27 Jan 2011 17:05:39 +0000 http://api.jquery.com/?p=74#comment-8663 I am trying to add a class to li with similar class for rest of li, on click event, but whenever i do that it does add class for a moment then load the page, I have used the following code.<br><br>$('.navLi a').click(function(){<br> $(this).addClass('selected');<br>});<br><br>Can Any one help me out.....thanks!!! I am trying to add a class to li with similar class for rest of li, on click event, but whenever i do that it does add class for a moment then load the page, I have used the following code.

$('.navLi a').click(function(){
$(this).addClass('selected');
});

Can Any one help me out…..thanks!!!

]>
By: Davidxiaozhi http://api.jquery.com/addClass/comment-page-1/#comment-8557 Davidxiaozhi Mon, 24 Jan 2011 13:47:44 +0000 http://api.jquery.com/?p=74#comment-8557 I like this demo,it is a nice func. I like this demo,it is a nice func.

]>
By: Dong http://api.jquery.com/addClass/comment-page-1/#comment-8503 Dong Fri, 21 Jan 2011 14:20:14 +0000 http://api.jquery.com/?p=74#comment-8503 it's useful func it's useful func

]>
By: Chenru8891 http://api.jquery.com/addClass/comment-page-1/#comment-8311 Chenru8891 Thu, 13 Jan 2011 11:56:10 +0000 http://api.jquery.com/?p=74#comment-8311 呵呵 看不懂 呵呵 看不懂

]>
By: Christopher Imrie http://api.jquery.com/addClass/comment-page-1/#comment-8287 Christopher Imrie Wed, 12 Jan 2011 18:33:10 +0000 http://api.jquery.com/?p=74#comment-8287 great feature great feature

]>
By: Nate http://api.jquery.com/addClass/comment-page-1/#comment-8231 Nate Mon, 10 Jan 2011 19:04:36 +0000 http://api.jquery.com/?p=74#comment-8231 When you call $('.slide_title_minus').click(function); jQuery searches for all elements with that class, and tries to assign a click handler to them. However, when that code runs there is no .slide_title_minus, so the event handler is never bound. Look up the jQuery function called live() When you call $('.slide_title_minus').click(function); jQuery searches for all elements with that class, and tries to assign a click handler to them. However, when that code runs there is no .slide_title_minus, so the event handler is never bound. Look up the jQuery function called live()

]>
By: potogas http://api.jquery.com/addClass/comment-page-1/#comment-8210 potogas Sun, 09 Jan 2011 01:06:08 +0000 http://api.jquery.com/?p=74#comment-8210 ok ok

]>
By: LFA http://api.jquery.com/addClass/comment-page-1/#comment-7889 LFA Wed, 29 Dec 2010 21:57:47 +0000 http://api.jquery.com/?p=74#comment-7889 Hello, i'm trying to switch a class dinamically on a div element but its not working properly. Here's my code<br><br> $('.slide_title_plus').click(function(){<br>$(this).next('.slide_content').slideToggle();<br>$(this).removeClass('slide_title_plus');<br>$(this).addClass('slide_title_minus');<br>return false;<br> });<br><br> $('.slide_title_minus').click(function(){<br>$(this).next('.slide_content').slideToggle();<br>$(this).removeClass('slide_title_minus');<br>$(this).addClass('slide_title_plus');<br>return false;<br> });<br><br>When I click a "slide_title_plus" class element, i want it to switch to the "slide_title_minus" class. The first time it works, but then I click on the same switched "slide_title_minus" element and it doesn't turn back into the first class<br><br>Any ideas? Hello, i'm trying to switch a class dinamically on a div element but its not working properly. Here's my code

$('.slide_title_plus').click(function(){
$(this).next('.slide_content').slideToggle();
$(this).removeClass('slide_title_plus');
$(this).addClass('slide_title_minus');
return false;
});

$('.slide_title_minus').click(function(){
$(this).next('.slide_content').slideToggle();
$(this).removeClass('slide_title_minus');
$(this).addClass('slide_title_plus');
return false;
});

When I click a “slide_title_plus” class element, i want it to switch to the “slide_title_minus” class. The first time it works, but then I click on the same switched “slide_title_minus” element and it doesn't turn back into the first class

Any ideas?

]>
By: LFA http://api.jquery.com/addClass/comment-page-1/#comment-7830 LFA Wed, 29 Dec 2010 13:57:47 +0000 http://api.jquery.com/?p=74#comment-7830 Hello, i'm trying to switch a class dinamically on a div element but its not working properly. Here's my code<br><br> $('.slide_title_plus').click(function(){<br>$(this).next('.slide_content').slideToggle();<br>$(this).removeClass('slide_title_plus');<br>$(this).addClass('slide_title_minus');<br>return false;<br> });<br><br> $('.slide_title_minus').click(function(){<br>$(this).next('.slide_content').slideToggle();<br>$(this).removeClass('slide_title_minus');<br>$(this).addClass('slide_title_plus');<br>return false;<br> });<br><br>When I click a "slide_title_plus" class element, i want it to switch to the "slide_title_minus" class. The first time it works, but then I click on the same switched "slide_title_minus" element and it doesn't turn back into the first class<br><br>Any ideas? Hello, i'm trying to switch a class dinamically on a div element but its not working properly. Here's my code

$('.slide_title_plus').click(function(){
$(this).next('.slide_content').slideToggle();
$(this).removeClass('slide_title_plus');
$(this).addClass('slide_title_minus');
return false;
});

$('.slide_title_minus').click(function(){
$(this).next('.slide_content').slideToggle();
$(this).removeClass('slide_title_minus');
$(this).addClass('slide_title_plus');
return false;
});

When I click a “slide_title_plus” class element, i want it to switch to the “slide_title_minus” class. The first time it works, but then I click on the same switched “slide_title_minus” element and it doesn't turn back into the first class

Any ideas?

]>
By: Lolol232 http://api.jquery.com/addClass/comment-page-1/#comment-7744 Lolol232 Thu, 23 Dec 2010 14:57:33 +0000 http://api.jquery.com/?p=74#comment-7744 Your common sense should ideally point that out. Your common sense should ideally point that out.

]>