JQuery DOM附加元素

时间:2015-09-02 00:00:23

标签: javascript jquery dom

我有一个代码,我可以在其中添加下一个输入字段,之后我使用此代码来获取数组

$("#mobiles input").each(function(){
array[$(this).attr("id")] = $(this).val();
});
$("#emails input").each(function(){
array[$(this).attr("id")] = $(this).val();
});

第一个ID“$("#mobiles input")”工作正常。但第二个不起作用。显示未定义...

HTML CODE:

<table id='mobiles'>
            <tr>
            <td><?php echo MOBILE; ?> 1</td>
            <td><input style='width: 250px;' type='text' id='mobile1'></td>     
            </tr>
            </table>

<table>
            <tr>
            <td style='width: 50px;'><img src='images/add_client/plus.png' style='cursor: pointer;' id='addMobile'></td>
            <td style='text-align: right; width: 260px;'><img id='deleteMobile' src='images/add_client/del.png' style='cursor: pointer;'></td>
            </tr>
</table>

<table id='emails'>
            <tr>
            <td><?php echo EMAIL; ?> 1</td>
            <td><input type='text' style='width: 250px; margin-left: 9px;' id='email1'></td>        
            </tr>
            </table>

            <table>
            <tr>
            <td style='width: 50px;'><img src='images/add_client/plus.png' style='cursor: pointer;' id='addEmail'></td>
            <td style='text-align: right; width: 260px;'><img id='deleteEmail' src='images/add_client/del.png' style='cursor: pointer;'></td>
            </tr>
</table>

0 个答案:

没有答案
相关问题