jQuery greatly simplifies JavaScript programming.
The jQuery library can be added to a web page with a single line of markup.
$(this).hide()
Demonstrates the jQuery hide() function, hiding the current HTML element.
$("p").hide()
Demonstrates the jQuery hide() function, hiding all <p> elements.
$(".test").hide()
Demonstrates the jQuery hide() function, hiding all elements, with class="test"
$("#test").hide()
Demonstrates the jQuery hide() function, hiding the element, with id="test".
Adding the jQuery Library to Your Pages
<head>
<script type="text/javascript" src="jquery.js"></script>
</head>
<script type="text/javascript" src="jquery.js"></script>
</head>
The following example demonstrates the jQuery hide() function, hiding all <p>
elements in an HTML document.
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body>
</html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body>
</html>
No comments:
Post a Comment