Method: 1. Use "$(selector).css('display','none');"; 2. Use "$(selector).attr("display","none" );"; 3. Use "$(selector).hide();"; 4. Use "$(selector).toggle();".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Four ways to hide and display elements in jquery
Method one:
$(selector).css('display','none'); $(selector).css('display','block');
Method two:
$(selector).attr("display","none"); $(selector).attr("display","block");
Method 3:
$(selector).hide(); $(selector).show();
hide() method: If the selected element has been displayed, hide the element.
show() method: If the selected elements have been hidden, display these elements
Method 4:
$(selector).toggle();
toggle() method in Switch between hide() and show() on the selected element.
This method checks the visible status of the selected element. If an element is hidden, show() is run, if an element is visible, hide() is run - this creates a toggle effect.
Recommended related video tutorials: jQuery Tutorial (Video)
The above is the detailed content of How to hide elements in jquery. For more information, please follow other related articles on the PHP Chinese website!