Tuesday, June 16, 2009

JQuery basics : working with divs and text boxes, and checking for null elements

Adding text to a div's innerHTML

$("div#some_div").append(s);


Getting text from a div

var text = $("div#some_div" ).html();


Getting/Setting value from text box

var text = $("#some_textbox").val();
$("#some_textbox").val("bla");


Checking if document element is null

if (!$("#some_elem").length){
...

}

No comments: