5

I want to convert HTML table to ul and li elements. my table structure is

<table>
    <tbody>
        <tr>
            <th>1974</th>
            <td>UK</td>
        </tr>
        <tr>
                <th>1976</th>
            <td>Street</td>
        </tr>
        <tr>
            <th>1976-2002</th>
            <td>visitors.</td>
        </tr>

    </tbody> 
 </table>

I tried to convert this to

        <ul>
            <li>
                <p>1974</p>
                <p>UK</p>
            </li>
            <li>
                    <p>1976</p>
                <p>Street</p>
            </li>
            <li>
                <p>1976-2002</p>
                <p>visitors.</p>
            </li>

        </ul> 

using jquery replaceWith function as below. Here I firstly going to convert <tbody> element.

$(document).ready(function() {
    $("tbody").each(function(){
    var html = $(this).html();
    $(this).replaceWith("<ul>" + html + "</ul>");
    });
)};

but this not give any positive answer. Anybody have any idea how to do this.

Thanks.

Miuranga
  • 2,463
  • 10
  • 51
  • 81
  • 1
    `
      ` isn't a valid markup, it should be `
      `.
    – yogi Feb 12 '13 at 09:08
  • Sorry, It is mistake. actually I want completely change table to list. i have updated above code. – Miuranga Feb 12 '13 at 09:10