smn Posted February 23, 2017 Share Posted February 23, 2017 Good morning! I've googled the question, but could not find the information. There is a <table> with random number of <td>s (each <tr> contains 3 <td>s). How to reverse the order of each <td> in this table? The initial order is: <table><tr><td1></td><td2></td><td3></td></tr> <tr><td4></td><td5></td><td6></td></tr></table> I need: <table><tr><td6></td><td5></td><td4></td></tr> <tr><td3></td><td2></td><td1></td></tr></table> Would appreciate any assistance or idea! Quote Link to comment https://forums.phpfreaks.com/topic/303277-how-to-reverse-order-of-s-in-a-using-jquery/ Share on other sites More sharing options...
cyberRobot Posted February 24, 2017 Share Posted February 24, 2017 You could use getElementsByTagName() to get the table and then all the columns for the table. More information can be found here: https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName Then you could loop through the columns, rebuild the table, and replace the old table with the new one. Quote Link to comment https://forums.phpfreaks.com/topic/303277-how-to-reverse-order-of-s-in-a-using-jquery/#findComment-1543327 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.