我正在尝试使用 jQuery 将表“new”添加到表“lasttable”中,但我无法获得结果。我是在做正确的事还是我误解了前置的含义?
<table id ="lasttable" class="add" border="1px" width="100%">
<tr class="header"><td class="location" colspan="7">New Item</td></tr>
</table>
我的 jQuery:
$("#lasttable").prepend("<table id=\"new\" class=\"add\" border=\"1px\" width=\"100%\">"
+"<tr class=\"header\"><td class=\"stretch\"><a class=\"eloc\" rel=\"leanModal\" href=\"#modal_location\"><img src=\"images/edit-icon.png\" alt=\"Location\"></a></td><td class=\"location\" colspan=\"6\"></td></tr>
+"</tbody></table>");
最佳答案
假设您损坏的选择器是错字,我认为您想要放置新表 .before()
现有的。
$("#lasttable").before("new content here");
关于javascript - 我可以使用 jQuery 将表添加到另一个表吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14234550/