Switch/toggle div (jQuery)

后端 未结 9 663
伪装坚强ぢ
伪装坚强ぢ 2020-12-01 09:39

I wish to accomplish a fairly simple task (I hope!)

I got two div tags and one anchor tags, like this:

forgot p         


        
9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 10:24

    I used this way to do that for multiple blocks without conjuring new JavaScript code:

    Show/Hide Content
    
    
    

    Then a JavaScript portion for all such cases:

    $(function() {
      $('*[data-toggle]').click(function() {
        $('#'+$(this).attr('data-toggle')).toggle();
        return false;
      });
    });
    

提交回复
热议问题