$(document).ready(function() {
… jquery code ..
});
$(function() {
… jquery code ..
});
$(“p”).html(“Test paragraph”);
$(“div#id”).remove();
$.each([ "foo", "bar", "baz" ], function( idx, val ) {
console.log( "element " + idx + " is " + val );
});
$(“div.class1”).hide();
$( "#content" ).find( "h3" ).html( "new text for the h3!" );
or
$( "#content" )
.find( "h3" )
.html( "new text for the third h3!" );
$(“div”).dblclick(function() {
$(this).hide();
});
$(“li”).bind(“click”, function() {
console.log(“list item was clicked”);
});
$(“p”).on(“click”, function() {
$(this).css(“background-color: red”);
});
$(“form”).on(“submit”, function(eventObj) {
// cancel default functionality for specific event (e.g. form submit)
eventObj.preventDefault();
… });
$(“p”).css(“background-color”)
$(“p”).css(“font-size”, “14px”)
$(“p”).css({color: “red”, width: “100%”, height: “100%”})
.fancy {
border: 1px dotted #00eeff;
background: url(“pic.jpg”);
}
jquery code:
$(“#div1”).addClass(“fancy”);
$(“#div1”).removeClass(“fancy”);
$(“#div1”).toggleClass(“fancy”);
$("button").click(function(){
$(“p”).hide(20);
$(“p#id1”).show(“slow”);
});
$("button").click(function(){
$("p").toggle();
});
$(“button”).click(function() {
$(“#div1”).fadeIn(“2000”);
});
$(“button”).click(function() {
$(“#div1”).slideUp(“2000”);
});
$("button").click(function() {
$("#div1").animate({left:’100px’, top: ’75px’});
});
$("button").click(function() {
$("#div1").animate({
left: ‘500px’,
opacity: ‘0.3’,
height: ‘100px’,
width: ’60px’
});
});
console.log($(“p”).text());
$(“p”).text(“Test..”);
console.log($(“div”).html());
$(“div”).html(“<p>Test</p>”);
console.log($(“a#id1”).attr(“href”));
$(“a#id1”).attr(“href”, “http://www.cs.ubbcluj.ro”);