JQuery notes

Posted on August 2, 2009 
Filed Under My Notes

Some key notes on jQuery.

Put HTML value in div box.

$(”#somediv”).html(’display_this’);

Put value in <input> element.

$(”#somediv”).val(’display_this’);

Apply CSS to a div box.

$(”#somediv”).css(”color”,”red”);

Ajax call.

$.ajax({
type: “POST”,
url: “some.php”,
data: “name=John&location=Boston”,

success: function(msg){
alert( “Data Saved: ” + msg );
}
});

DIV click action.

$(”#somediv”).click(function(event){

alert(”Clicked!”);
});

jQuery init wrapper.

$(document).ready(function(){
// Your code here
});

Comments

Leave a Reply