Return to Snippet

Revision: 48837
at July 11, 2011 20:28 by Alwaison


Updated Code
function initShowHideContent(){
    if($('a.show-hide').length){
        $('a.show-hide').each(function(){
            if($(this).hasClass('hide')){
                $(this).next().hide();
            }
        });
        $('a.show-hide').click(function(){
            $(this).next().toggle();
            if($(this).hasClass('hide')){ 			
                $(this).removeClass('hide').addClass('active');
            }else{ 
                $(this).removeClass('active').addClass('hide');
            }
            return false;
        });
    }	
}

Revision: 48836
at July 11, 2011 20:26 by Alwaison


Initial Code
function initShowHideContent(){
	if($('a.show-hide').length){
		$('a.show-hide').each(function(){
			if($(this).hasClass('hide')){
				$(this).next().hide();
			}
		});
		$('a.show-hide').click(function(){
			$(this).next().toggle();
			if($(this).hasClass('hide')){ 				$(this).removeClass('hide').addClass('active'); 				
			}else{ 
				$(this).removeClass('active').addClass('hide'); 
			}
			return false;
		});
	}	
}

Initial URL
http://jsfiddle.net/Alwaison/7d8Bu/

Initial Description

                                

Initial Title
Toggle element in jQuery

Initial Tags
event, jquery

Initial Language
jQuery