Home > Groups > Web Development > Write first jquery program

Write first jquery program

Article
Published in

To write first jquery program follow the below steps: -

1) Download the jquery file from http://docs.jquery.com/Downloading_jQuery

2) include jquery js file in <head> section of your html page

3) create a div element in body tag

<div id="test">write text here</div>

4) Now we will show and hide above div on click of a element <a>

5) create <a href="#" id="click_test">Click Here</a> outside the div and inside the body tag

6) now write following code in head section or body section

<script type="text/javascript">

$(document).ready(function(){

$("#click_test").click(function(){

$("#test").toggle();

return false;

});

});

</script>

-------------------------------------------------------------------------------------------------------------------------

7)

Full Example Code copy and paste:-

 

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

$(document).ready(function(){

$("#click_test").click(function(){

$("#test").toggle();

return false;

});

});

</script>

</head>

<body>

<a href="#" id="click_test">Click Here</a>

<div id="test">write text here</div>

</body>

</html>

this code will show/hide div on click of <a>

For more examples go to the http://docs.jquery.com

Your rating: None Average: 2 (1 vote)

Bookmark and Share
Home Back To Top