?
Solved

insert a tr tag using jquery

Posted on 2013-06-26
3
Medium Priority
?
276 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 800 total points
ID: 39279784
$(str).insertBefore("#sa");
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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…

743 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