Results 1 to 2 of 2

Thread: JQuery Delay in adding and removing classes.

  1. #1
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    297
    Thanks
    5
    Thanked 18 Times in 18 Posts

    Default JQuery Delay in adding and removing classes.

    Hello, Im using jquery to add and remove classes. However, i want it to delay the removal or addition of the class. Here is my query:

    Code:
    $('div.dropper').click(function(){
    	if($(this).children('.sub_title').hasClass('closed')){
    		$(this).children('.sub_title').removeClass('closed').addClass('opened');
    		$(this).children('.content').slideDown(300);
    	}else{
    		$(this).children('.content').slideUp(300);
    		$(this).children('.sub_title').delay(300).addClass('closed').removeClass('opened');
    		
    	}
    	});
    What I'm trying to do is when the content finishes scrolling up then i want the class to change.

    Any ideas? Thanks
    Last edited by Deadweight; 10-14-2013 at 04:05 PM.
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

  2. #2
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    297
    Thanks
    5
    Thanked 18 Times in 18 Posts

    Default

    Actually i figured it out and ill post it here to show you my solution:
    Code:
    $('div.dropper').click(function(){
    		if($(this).children('.sub_title').hasClass('closed')){
    			$(this).children('.sub_title').removeClass('closed').addClass('opened');
    			$(this).children('.content').slideDown(300);
    		}else{
    			$(this).children('.content').slideUp(300);
    			
    			$(this).children('.sub_title').delay(300).queue(function(reset_delay){
    				$(this).addClass('closed').removeClass('opened');
    				reset_delay();
    				});
    			
    
    			
    		}
    	});
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

Similar Threads

  1. Adding delay in Text and Image Crawler
    By johnfb in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 08-11-2010, 09:11 AM
  2. DD Tab Menu - adding a delay
    By reyn in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 02-06-2009, 07:14 PM
  3. Adding a delay
    By crimsonsmeagol in forum Flash
    Replies: 2
    Last Post: 09-09-2008, 05:08 PM
  4. [DHTML] Removing parts from the DOM using classes
    By molendijk in forum Submit a DHTML or CSS code
    Replies: 13
    Last Post: 01-11-2008, 01:15 PM
  5. Adding a delay to menu collapse
    By raks in forum CSS
    Replies: 1
    Last Post: 08-25-2007, 05:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •