How to insert markup into a table using javascript -
I have a table row with four cells. I am trying to use JavaScript to insert:
& lt; / Tr & gt; & Lt; Tr & gt;
Between the two cells which basically make one to two rows (at certain screen sizes).
I need to change it:
& lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt;
In:
& lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt;
This is my script:
$ ('table tr td: nth-child (3)'). ('& Lt; / tr & gt; & lt; tr & gt;');
And what I find here:
& lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; TR & gt; & Lt; / TR & gt; & Lt; --- Note that & lt; / Tr & gt; & Lt; Tr & gt; & Lt; Tr & gt; & Lt; / Tr & gt; it happens! & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; TD & gt; Accessories & lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt;
Tags are displayed in the right place, but they are switched around!
What's going on here? Can you add any other line and the last two code> elements in the new row td
$ ('& lt; tr & gt;') insertAfter ('tr'). Attachments ($ ('td'). Piece (-2))
Comments
Post a Comment