.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Code Snippets >> JQuery >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Set innerText using jQuery

Posted By:JQuery Developer       Posted Date: May 20, 2013    Points: 40    Category: JQuery    URL: http://www.dotnetspark.com  

This JQuery code example to show how to set innerText of an element or control in our web form using JQuery

innerText property equivalant in JQuery is .Text()

In Javascript we have a property like innerText and is there any similar method or property available in JQuery to modify text of an element.

Yes! we have .Text() method in JQuery which will internally call innertText property of javascript.

Lets see an example with div tag with id myDiv

<div id="myDiv">       

now in document.ready add "Hello World" to this div tag

$(document).ready(function () {
    $("#myDiv").text("Hello World");


Click here for live demo

Similarly if you want to modify innerHTML property. As we have .HTML() in JQuery to modify the html content of an element

If you would like to change the innerHTML property using JQuery please refer below code sample

Set innerHTML using jQuery


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend