javascript - how to convert/transform an HTML table tbody (with rowspans) TO json? -


i have html table combined row td's, or how say, don't know how express myself (i not @ english), show it! table:

<table border="1">     <thead>         <tr>             <th>line</th>             <th>value1</th>             <th>value2</th>         </tr>     </thead>     <tbody>         <tr>             <td rowspan="2">1</td>             <td>1.1</td>             <td>1.2</td>         </tr>         <tr>             <td>1.3</td>             <td>1.4</td>         </tr>         <tr>             <td rowspan="2">2</td>             <td>2.1</td>             <td>2.2</td>         </tr>         <tr>             <td>2.3</td>             <td>2.4</td>         </tr>     </tbody> </table> 

(you can check here)

i want convert table json variable jquery or javascript. how should like, , how should it? thank you, if can me!

if want convert text use 1 :

var array = [];  $('table').find('thead tr').each(function(){     $(this).children('th').each(function(){       array.push($(this).text());     }) }).end().find('tbody tr').each(function(){     $(this).children('td').each(function(){       array.push($(this).text());     })  })  var json = json.stringify(array); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -