javascript - jQuery: How do I insert column into table? -


i have table , i'm trying insert column left , right of given value on first row. can see demo of here: http://jsfiddle.net/ismailp/vjvam/1/

<table>     <tbody>         <tr>             <td>tag 1</td>             <td>tag 2</td>             <td>tag 3</td>             <td>tag 4</td>             <td>tag 5</td>             <td>tag 6</td>         </tr>         <tr>             <td>some other value1</td>             <td>some other value1</td>             <td>some other value1</td>             <td>some other value1</td>             <td>some other value1</td>             <td>some other value1</td>         </tr>     </tbody> </table> 

i've got working single row in table not n+1 rows. jquery guru me out here?

thanks!

see this: demo

 $("tbody tr").each( function() {    $(this).find("td:eq(" + cellbefore + ")").after("<td>" + splicefirst + "</td>");    $(this).find("td:eq(" + cellafter + ")").after("<td>" + splicelast + "</td>");  }); 

simplified: demo2

 $("tbody tr").each( function() {     $(this).find("td:eq(" + column + ")").after("<td>" + splicefirst + "</td>").before("<td>" + splicelast + "</td>");  }); 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -