Results 1 to 2 of 2

Thread: Inserting a variable within an append function in JQuery?

  1. #1
    Join Date
    Jul 2008
    Posts
    22
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Inserting a variable within an append function in JQuery?

    Hi,

    I have a Javascript variable name called "mouse" which has a string of text stored in it. I am also appending some HTML code to my exisiting HTML using JQuery:

    Code:
    var mouse = "Phone number";
    
     $(document).ready(function(){
    $('div.mynav').append("<div id='mine'>MY MOUSE VARIABLE HERE</div>");
    });
    How do I insert my variable apple where it says "MY MOUSE VARIABLE HERE"?

    Thanks in advance

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Code:
    var mouse = "Phone number";
    
    $(document).ready(function()
    	{
    	$('div.mynav').append("<div id='mine'>"+mouse+"</div>");
    	});
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

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
  •