javascript - 我可以使用 jQuery 将表添加到另一个表吗?

标签 javascript jquery

我正在尝试使用 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/

相关文章:

javascript - 如何通过鼠标移动 Angular 旋转正方形跟随鼠标?

jquery - 使用 jQuery 的 Google Wonder Wheel/Google Plus Circles 动画

javascript - Ajax查询json源码并输出结果

javascript - Chartjs 上的图例出现问题

javascript - React Native 中 ReactDOM 和 document.body 的等效变量是什么? (世博会)

javascript - 如何使用Jquery遍历表中当前行的所有列

如果值大于 javascript div 长度

jquery - 带有 jquery 效果问题的固定定位左侧菜单?

javascript - 未捕获的类型错误 : Property '$' of object - jQuery

javascript - 在discord.js 中设置 channel 权限时遇到问题