Set, Get innerHTML in jQuery Example

Setting & Getting innerHTML in jQuery


In JavaScript we set and get the content in div or table or any other field we get it using Object.innerHTML. e.g: document.getElementById("field").innerHTML

To set HTML content into div
document.getElementById("field").innerHTML="Value going to display in the field";
To get HTML content in the field/ specified Id.
var val=document.getElementById("field").innerHTML;

Similarly in jQuery we are setting the value using the below code

To get value in a div, span, table or any field expect input field
var val= $("field").html();
To Set value in a div, span, table or any field expect input field
$("field").html("Value going to displayed");

The above methodology is mostly used in Ajax concept and form validation.


Related Topic Ascending and Descending Order DIV Sorting in PHP
Dynamic Image Download
How to Create the Dynamic Folder Tree Links Navigation
Developer Code for JS Timer
Javascript Libraries List

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback