Home > Article > Web Front-end > jquery hide toolbar
In web design, sometimes we need to hide some toolbars or buttons to increase the beauty and simplicity of the page. This function can be achieved very easily using jQuery.
First you need to create an HTML page containing a button or toolbar and add the jQuery library to it. Next, we can easily hide related elements using the following code:
$(document).ready(function(){ $("button").click(function(){ $("工具栏的选择器").hide(); }); });
Here we define a button named "button" and use jQuery's click()
function to listen for click actions. When the button is clicked, the hide()
function will be called to hide the specified toolbar.
In addition to the hide()
function, there is also the show()
function that can be used to display hidden elements.
In addition, in order to avoid hidden elements leaving blank areas, we can use the slideDown()
and slideUp()
functions to let the elements rise in the form of animation or decline.
$(document).ready(function(){ $("button").click(function(){ $("工具栏的选择器").slideDown(); }); });
Here, when the button is clicked, use the slideDown()
function to animate the toolbar.
Similarly, the slideUp()
function can hide elements in an animated manner.
In addition, we can also use the CSS properties display:none
and display:block
to hide and show elements. This method instantly hides or shows the element without animation.
$(document).ready(function(){ $("button").click(function(){ $("工具栏的选择器").css("display", "none"); }); });
Here, when the button is clicked, use the CSS property display:none
to hide the toolbar.
In general, it is very simple and convenient to use jQuery to hide toolbars or buttons. We can choose to use the hide()
and show()
functions, the slideDown()
and slideUp()
functions, or CSS propertiesdisplay:none
and display:block
to achieve this. Either way, you can make the page more beautiful and concise.
The above is the detailed content of jquery hide toolbar. For more information, please follow other related articles on the PHP Chinese website!