Following our jQuery download tutorial, we have created a simple tutorial on how to hide an element on a webpage. The video tutorial can be viewed next, and the step by step guide below.
- Create a new folder in your documents containing the latest jQuery file.
- Create a new HTML document in the same folder as the jquery file.
- Open the HTML document in a text editor and add in the following code;
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html>
<head>
<title>jQuery Example</title>
<script type=”text/javascript” src=”jquery-1.7.1.min.js”></script>
<script type=”text/javascript”>
$(document).ready(function(){
$(“#clickMe”).click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p id=”clickMe”>Click me and I will disappear!</p>
<p>I will not disappear.</p>
</body>
</html>
The code highlighted in red are the elements which have been added in for this jQuery example to work.
The element in the body with the id=”clickMe” will follow the rules set in the header script, where as the other will just display as normal.
- Save changes to the HTML document
- Open the HTML document in a browser to view the working webpage
Click on the top line and watch it disappear
Click on the remaining line – it shouldn’t budge!

