Hiding ‘Div’ Tag in JavaScript and JQuery

JavaScript

Step 1: Add a page named ‘Default.aspx’ by right-clicking on the project in Solution Explorer and click on "Add" -> "New Item".


Step 2: Follow the mentioned below Sub-steps:

  • Add a ‘div’ tag and an ‘input’ tag which contains type=button.
  • Add a function named ‘show_hide()’ in the javascript which will hide the ‘div' tag.
  • Add the onclick event in the input tag with the calling of ‘show_hide()’


Step 3: Run the Application and click on the button to hide the ‘Div’.


Result


JQuery 

Step 1: Download the JQuery Library file from the http://jquery.com/download/. Either it's jquery-1.11.0.min.js or it's jquery-1.11.0.js and save it in your project.

Note: In the article I am using jquery-1.4.0.js.


Step 2: Add a page named ‘Default.aspx’ by right-clicking on the project in Solution Explorer and click on "Add" -> "New Item" and then follow the Sub-steps given below:

  • Add a ‘div’ tag and an ‘input’ tag which contains type=button.
  • Add some code in the script tag which will hide the ‘div' tag after clicking on the button.


Step 3: Run the Application and click on the button to hide the ‘Div’.


Result