- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to add display:none in an HTML element using jQuery?
To workaround with display: none in an element in jQuery, use the hide() method. It will do the same work.
Example
You can try to run the following code to learn how to add display:none in an HTML element −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").removeAttr("style").hide(); }); }); </script> </head> <body> <h1>Heading 1</h1> <p style="font-size:15px">This is demo text. This will hide on button click.</p> <p>This is another text. This will hide on button click</p> <button>Hide</button> </body> </html>
- Related Articles
- How to add attributes to an HTML element in jQuery?
- How to get HTML content of an element using jQuery?
- How to set HTML content of an element using jQuery?
- How to add an element horizontally in HTML page using JavaScript?
- How to add and remove CSS classes to an element using jQuery?
- How to add description list of an element using HTML?
- How to add an address element in HTML?
- How to remove all the attributes of an HTML element using jQuery?
- How can I show and hide an HTML element using jQuery?
- How to append an element before an element using jQuery?
- How to append an element after an element using jQuery?
- How to clone an element using jQuery?
- How to add class to an element without addClass() method in jQuery?
- How to add a new list element under a using jQuery?
- How to add an event handler to an element in JavaScript HTML DOM?

Advertisements