Solved

insert a tr tag using jquery

Posted on 2013-06-26
3
268 Views
Last Modified: 2013-06-26
Hello.
 How do I add a TR tag in a particular section..

e.g
<table id="tbl1">
  <tr id="ca">
  </tr>
  <tr id ="sa">
  </tr>
</table>

I would to add a tr tag after TR with ID = ca and before id = sa

<table id="tbl1">
  <tr id="ca">
  </tr>
<tr id="XX">
  </tr>

 <tr id ="sa">
  </tr>
</table>
0
Comment
Question by:SiemensSEN
  • 2
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39279742
$("<tr id='ca' />").insertBefore("#sa");

Test page : http://jsfiddle.net/unQbh/
0
 

Author Comment

by:SiemensSEN
ID: 39279782
Sorry..
Here is my TR string to insert
 
str += "<tr>";
                          str +="<td class='tableCell_5percent'> </td>";
                          str +="<td class='tableCell_25percent'> </td>";
                          str +="<td class='tableCell_5percent'> </td>";
                          str +="<td class='tableCell_65percent labels'>"+psets[ps].Name+"</td>";
                          str +="</tr>"

Open in new window


How do I insert it after the row with ID='ca'
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 200 total points
ID: 39279784
$(str).insertBefore("#sa");
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

by Julian Matz As of jQuery (http://jquery.com/) 1.4 the .live() method (http://api.jquery.com/live/) supports custom events as well as some standard JavaScript events that it previously didn't support. Among these is the submit event. Unlike …
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now