jquery – starter tutorial #1

To start with jquery is a simpler task. To use jquery is a fun. Here is a starter.

$ refers to jquery

$(this).hide()
Demonstrates the jQuery hide() method, hiding the current HTML element.

$(“#test”).hide()
Demonstrates the jQuery hide() method, hiding the element with id=”test”.

$(“p”).hide()
Demonstrates the jQuery hide() method, hiding all <p> elements.

$(“.test”).hide()
Demonstrates the jQuery hide() method, hiding all elements with.

<html>
<head>
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});

$(document).ready(function(){
  $("#idtest").click(function(){
    $(this).hide();
  });
});

$(document).ready(function(){
  $(".classtest").click(function(){
    $(this).hide();
  });
});

</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
<div id="idtest">hide this div with id idtest</div>
<span>hide this span with classtest idtest</span>
</body>
</html>

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s