JQuery Syntax - Examples
1. The #id Selector
$(document).ready(function(){
$("button").click(function(){
$("#test").hide();
});
});
2. The .class Selector
$(document).ready(function(){
$("button").click(function(){
$(".test").hide();
});
});
3. jQuery hide() and show()
$("#hide").click(function(){
$("p").hide();
});
$("#show").click(function(){
$("p").show();
});
4. jQuery animate()
$("button").click(function(){
$("div").animate({left: '250px'});
});
5. jQuery Get
$("#btn1").click(function(){
alert("Text: " + $("#test").text());
});
6. jQuery Set
$("#btn1").click(function(){
$("#test1").text("Invalid password!");
});
7. jQuery append()
$("#btn1").click(function(){
$("p").append("Some appended text.");
});
8. jQuery prepend()
$("#btn1").click(function(){
$("p").prepend("Some prepended text.");
});