Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 21-09-2009
Member
 
Join Date: Oct 2008
Posts: 100
How to addclass and remove class using jquery

How to add and remove classes using jquery following is an example where I have downloaded from the internet and want to have an understanding about how jquery will be executed. I have tried understanding the code many times but this always makes me confusing.

Code:
$(document).ready(function(){
  $("#menu li:last").addClass('last');
  $("#menu li li:last").addClass('sublast');
});
Any help would be appreciated.
Reply With Quote
  #2  
Old 21-09-2009
Member
 
Join Date: Oct 2008
Posts: 167
Re: How to addclass and remove class using jquery

In the code completion already helps to fill in the strings inside the jQuery dollar function. The jquery checks for the slid class. This changes the background position of the image in the post-collapse class, for aesthetic purposes exchanging a + mark for a – mark. NetBeans knows the return type of the dollar function so it will only presented with jQuery methods.
Reply With Quote
  #3  
Old 21-09-2009
Member
 
Join Date: Feb 2006
Posts: 159
Re: How to addclass and remove class using jquery

The jQuery UI effects core extends the base class API to be able to animate between two different classes. The following methods are changed. To add a class we may use the following class declaration such as 'selected' and 'highlight' to the matched elements.

Code:
$("p:last").addClass("selected highlight");
They also accept three additional parameters: speed, easing (optional), and callback.
Reply With Quote
  #4  
Old 21-09-2009
Member
 
Join Date: Dec 2008
Posts: 183
Re: How to addclass and remove class using jquery

addClass is for adding CSS classes to elements. If you're looking to change some CSS property by tweening, then you need to do that explicitly using Effects. when NetBeans knows the return type of a function, it's shown in code completion item separated by a colon. addClass is definately a great way of keeping track of something like this, especially in a WordPress environment where there may be many post classes on the page (such as an index page, category page etc.,).
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to addclass and remove class using jquery"
Thread Thread Starter Forum Replies Last Post
Upgrade Sony Ericsson Xperia Play Micro SD card from class 2 8GB to class 4 32GB Aaryan2011 Portable Devices 8 08-10-2011 11:06 PM
jQuery AJAX vs. Adobe AIR AJAX Class Agaev Windows Software 5 06-07-2010 01:59 PM
How to initialize a derived class with an instance of the base class in c#? KAIRU26 Software Development 5 12-02-2010 06:23 PM
DOM elements : remove with jQuery Servant Software Development 4 30-01-2010 10:32 AM
Good news for CBSE CLASS X & CLASS IX - visit learnnext surya_expert Education Career and Job Discussions 0 13-12-2008 12:09 PM


All times are GMT +5.5. The time now is 07:04 AM.