jquery toggle slideUp/slideDown

后端 未结 3 588
孤独总比滥情好
孤独总比滥情好 2021-01-17 22:45

I\'ve got a div#items and if it\'s clicked then div#choices slideDown(). If it\'s clicked again then div#choices should slideUp(); How can I test if choices is down or up al

3条回答
  •  鱼传尺愫
    2021-01-17 23:05

    Try this -


    HTML:

    Show
    
    


    JQUERY SCRIPT:

    $('.nav-toggle').click(function(){
       var content_id = $(this).attr('href');               
       var toggle_switch = $(this); 
         $(content_id).toggle(function(){
        if($(this).css('display')=='none'){
              toggle_switch.html('Show');
        }else{
          toggle_switch.html('Hide');
            }
        });  
    });
    

提交回复
热议问题