SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getting a javascript variable into html

    hi i have a javascript variable which i need to insert into HTML like <p><a href="#">i am a link</a> for " + theNewVar + " sentence.</p>

    can you help?

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code HTML4Strict:
    <p><a href="#">i am a link</a> for <span id="special"></span> sentence.</p>
    Code JavaScript:
    var span = document.getElementById("special");
    span.appendChild(document.createTextNode(theNewVar));
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •