jQuery - Toggle div class on click

前端 未结 3 1416
心在旅途
心在旅途 2021-01-25 07:31

No, this is not a straight forward toggle question. I am aware of the toggle() functions and how to simply hide/show a div. Imagine a box with a label inside:

         


        
3条回答
  •  感动是毒
    2021-01-25 08:17

    $('.section').click(function() {
        $(this).removeClass('hidden');
    });
    
    $('.section-legend').click(function(e) {
        var $parent = $(this).parent();
        if(!$parent.hasClass('hidden')) {
            $parent.addClass('hidden');
            return false;
        }
    });
    

提交回复
热议问题