Results 1 to 2 of 2

Thread: add extra text to a div using jquery

  1. #1
    Join Date
    Feb 2005
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default add extra text to a div using jquery

    Hi all

    This might be impossible, but i'm sure i read some where before that jquery could add text to a page.

    Basically i want to add a short snippet of text to the below line:

    Code:
    <div class="prodprice"><strong>Price:</strong> <span class="price" id="pricediv0">33.99</span> </div>
    i simple want to add the text "inc. Vat" after the price in the above code. However ideally i'd like a different style added to it.

    If anyone can advise on how i could go about this with jquery would be great

    thanks
    James

    IGNORE THIS MESSAGE, SORTED THE PROBLEM... CANT SEE HOW TO DELETE THREAD...
    Last edited by isntworkdull; 07-29-2010 at 10:07 PM. Reason: SORTED OUT

  2. #2
    Join Date
    Oct 2009
    Posts
    845
    Thanks
    14
    Thanked 189 Times in 188 Posts

    Default

    I see you figured it out already, but i'm gonna post my suggestion anyway in case somebody else wonder how it can be done.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Inc.Vat</title>
    
    <style type="text/css">
    .vat {
    	color: blue; 
    	font-weight: bold; 
    	font-family:Georgia, "Times New Roman", Times, serif;
    	font-size:12px;
    	font-style:italic; 
    	padding-left: 6px;
    }
    </style>
    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    
    <script type="text/javascript">
    jQuery(document).ready(function($) {
    $('.prodprice').append('<span class="vat">inc. Vat</span>');							   
    });
    </script>
    
    </head>
    <body>
    <div class="prodprice"><strong>Price:</strong> <span class="price" id="pricediv0">33.99</span> </div>
    </body>
    </html>

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
  •