Solved

insert a tr tag using jquery

Posted on 2013-06-26
3
269 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Correct this jQuery code for opening div. 24 19
update field on focusout 15 43
fade new row in after record insert with jQuery/ajax/php 18 73
jQuery Syntax 2 47
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

911 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

23 Experts available now in Live!

Get 1:1 Help Now