#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    19
    Rep Power
    0

    Generating text and dynamically insert it on a webpage


    Hi, I have a code, that inserts generated data on a website, one line of the code looks like this:

    Code:
    variable.append("<tr><td>&nbsp;</td></tr>");
    but if I change it, e.g. making a link from the inserted text:

    Code:
    variable.append("<tr><td><a href=google.com>&nbsp;</a></td></tr>");
    it doesn't work anymore (shows no data at all).

    How should I go about this?
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,165
    Rep Power
    184
    This is how you need to go about doing this and here is the link to the jQuery .append() API:http://api.jquery.com/append/.
    Code:
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script>
    var variable;
    $("document").ready(function(){
       $("body").append("<tr><td><a href=\"http://google.com\">Google</a></td></tr>");   
    });
    </script>

IMN logo majestic logo threadwatch logo seochat tools logo