Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I insert text at the end of a <TD> in a html table cell

I have a table and in a cell I have something like this . .

  <td class="quantity">
         [a bunch of spans and divs and all stuff]
  </td>

I want to figure out in jquery how I could insert text at the bottom of the cell, so the result would be:

  <td class="quantity">
         [a bunch of spans and divs and all stuff]
         inserted text
  </td>

I need it to work, regardless of what else is in the td (in the "a bunch of spans and divs and all stuff" section.

Is that possible?

like image 887
leora Avatar asked Oct 15 '11 13:10

leora


2 Answers

with jquery:

$("td.quantity").append("stuff you want to append");

The append function always adds to the end of the element you provided. In this case it will add to all the td with the class quantity

like image 70
fmsf Avatar answered Nov 14 '22 10:11

fmsf


$('.quantity').append('inserted text');

http://jqapi.com/#p=append

like image 30
Riz Avatar answered Nov 14 '22 10:11

Riz