Running initialization code:
$(document).ready(function(){
// your init code here
});
Selecting elements
var els = $("#myid"); // all elements having id "myid"
var els = $("[txt]"); // elements with attribute txt
Modifying content
els.addClass("hide");
els.removeClass("hide");
els.hasClass("hide"); // true if at least one element has this class
var attr = el.attr("myattr"); // value of attribute "myattr"
el.attr("myattr", "attrval"); // set value of attribute "myattr" to "attrval"
var txt = els.text();
els.text("new text");
els.replaceWith("txt"); // replace element with "txt"
Enable/disable element
$("#id").attr("disabled","disabled");
$("#id").removeAttr("disabled");
Misc
$("#id").focus() - to focus on a given element e.g. text input element
Handling radio buttons
$("#id").attr("checked", "checked"); // select a radio button
Handling checkboxes
$("#id").is(":checked") - returns true if a checkbox button is checked
|