Problem with changing td's html in JQuery.

Posted by bugbug on Stack Overflow See other posts from Stack Overflow or by bugbug
Published on 2010-03-19T05:32:17Z Indexed on 2010/03/19 5:41 UTC
Read the original article Hit count: 126

Filed under:
|
|
|

I want to change text in table td from 1,1,1 to 1,2,3 with following code,
But it not seem to work. what is wrong in my code?

This is my JavaScript function.

    function reorder(targetId){
        var i = 1;
        jQuery.find(targetId).each(function(){
            jQuery(this).attr("innerHTML", i);
            i ++;
        });
    }

My html code.

<form>
    <input type="button" onClick="reorder('#index');" value="test"/>
    <table>
        <tr><td id="index">1</td></tr>
        <tr><td id="index">1</td></tr>
        <tr><td id="index">1</td></tr>
    </table>
</form>

© Stack Overflow or respective owner

Related posts about jqury

Related posts about table