DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   

how to set text or HTML content for span using jquery/Javascript

By Ashok Nalam on 14 Mar 2013 | Category: JavaScript & Jquery | Tagged: string 
  Discuss Add Comment   |  
Add rating Rate this resource  [Rated 4.00/5 by 1 people] 
In order to set value/text or html to span element using JQuery/Javascript, using the following code
<span id="mySpan"></span>

using JQuery:

$("#mySpan").text("setting span text using juery"); // setting text
$("#mySpan").html("<h3>setting span html using</h3> <b>juery</b>"); // setting html

using Javascript:

var spanEle =document.getElementById('mySpan');
spanEle.innerText = "setting span text using Javascript"; //setting text spanEle.innerTHTML = "<h3>setting span html using</h3> <b>javascript</b>"; // setting html


  Discuss Add Comment    
Add rating Rate this resource  [Rated 4.00/5 by 1 people] 
About the Contributor
Member Since : 10 Dec 2012
Member Points (Level) : 8666  (Professional)
Location : INDIA
Home Page : http://dotnetmirror.com
About : I am admin of this site.
Rate this resource
 
Add your Comment
Name Email WebSite
Captcha Refresh


Comments (0)
No comments found, click here to add comment.