HTML and CSS Reference
In-Depth Information
Set and Retrieve Input Values
jQuery can set and retrieve the property value of input elements such as textboxes (Listing 6-41).
Listing 6-41. Get and Set Textbox Values
// Get the value of a textbox
var TextboxValue = $("#TextboxID").val();
// Set the value of a textbox
$("#TextboxID").val("New Textbox Value");
Set and Retrieve Element Markup Content
The markup content of elements can be manipulated with the html function (Listing 6-42).
Listing 6-42. Get and Set Markup Content
// Get the markup content of an element
var DivHTML = $("#DivID").html();
// Set markup content
$("#DivID").html("<p>The updated markup content.</p>");
Set and Retrieve Element Text
The textual content of elements can be manipulated with the text function (Listing 6-43).
Listing 6-43. Get and Set Textual Content
// Retrieve the textual content of an element
var DivText = $("#DivID").text();
// Set the textual content of element
$("#DivID").text("The new textual content.");
Set and Retrieve Element Dimensions
The dimensions of markup elements can be retrieved and changed using the height and width jQuery functions
(Listing 6-44).
 
Search WWH ::




Custom Search