All TalkersCode Topics

Follow TalkersCode On Social Media - A Social Media Network for developers Join Now ➔

How To Hide Button In jQuery

Last Updated : Mar 11, 2024

How To Hide Button In jQuery

In this article we will show you the solution of how to hide button in jQuery, as we know in jquery for hide elements we have more choice like using display property at css(), attr(), prop() or hide(). Here we are going to use hide() method for achieve the result.

The hide() method hides the selected elements. So with the help of this method we can easily hide any element in html document.

Step By Step Guide On How To Hide Button In jQuery :-

In html we defined two buttons with class, id attributes, first button shows hide example and second button helps for proceeds process.

In script block we defined ready() method which is automatically starts loading code of within this function when this program opened on browser.

There we appended click() method on button ‘hideBTN’ and within this we specified button ‘btn’ then which is appends with hide() method for hides the selected element.

<!DOCTYPE html>
        <title>Hide button in jquery</title>
        <script src=""></script>
        <button class="btn">Example Button</button>
        <button id="hideBTN">Hide</button>
  1. <!DOCTYPE html> tag which is instruct the web browser about what version of HTML file written in and it’s not have any ending tag.
  2. The<html> tag is used to indicate the beginning of HTML document.
  3. As above shown <head> tag is contain information about webpage and external file links are declared here. <title> tag is used for set the webpage title.
  4. Here we imported open source jquery library support file which is needed for coding using jquery in program.
  5. Both <head> and <title> tags having their pair end tag, so we need to close the ending tags respectively. If you’re not closed anyone of ending tag properly that is also affect the webpage result.
  6. <body> tag is beginning of main coding part because it contain coding of entire website blocks and elements described here.
  7. We defined two button with class, id attributes, first button ‘Example Button’ defined with class attribute ‘btn’ and second button ‘Hide’ defined with id ‘hideBTN’ for proceeds process when user clicks on it.
  8. In script we defined ready() method within that we appended click() method on button ‘Hide’ by id attribute ‘hideBTN’. There we specified button ‘Example Button’ by class attribute ‘btn’ and which is appends with hide() method for hides the button.
  9. Both </body>,</html> tags closed respectively. </body> tag indicates the end of body, Then </html> tag indicates the end of HTML document.

Conclusion :-

In conclusion now we are able to know how to hide button in jquery. Before execution of program we needs to confirm internet connection because then only that jquery file will supports defined jquery codes without error.

When we executes program on browser we can see two buttons ‘Example Button, Hide’ now user needs to clicks on ‘Hide’ then we can see button ‘Example Button’ gone to hidden state.

I hope this article on how to hide button in jQuery helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Pragati

Experienced coding content writer who enjoys breaking down complex concepts in programming languages like Java, Python, C, and C++. Over three years of experience producing interesting and relevant content for a variety of entities. Committed to providing concise and easy-to-understand articles that assist readers in easily understanding technology and industry trends in the world of coding and software development.

Follow Pragati On Linkedin 🡪