使用按钮单击按钮添加表格
16lz
2021-01-22
I'm trying to add a table using jQuery's appendTo
function whenever a certain button is clicked. Here's my code:
我试图在点击某个按钮时使用jQuery的appendTo函数添加一个表。这是我的代码:
$("#button").click(function() {
$("#divId").dialog("open");
$('#divId').appendTo('.table_width');
});
Note that in this code, .table_width
is the table class and #divId
is the div identity. However, this does not seem to be working. Am I doing this the right way? Thanks in advance for any help.
请注意,在此代码中,.table_width是表类,#diviv是div标识。但是,这似乎不起作用。我这样做是对的吗?在此先感谢您的帮助。
3 个解决方案
#1
1
Use .append
instead of .appendTo
. What I understand from your question is that you want to append an existing table to #divId..appendTo
will append your div to the table, which is not what you want.
使用.append而不是.appendTo。我从你的问题中理解的是你想要将现有的表附加到#divId..appendTo会将你的div附加到表中,这不是你想要的。
更多相关文章
- 代码点火-如何从控制器返回Json响应
- 是否可以从节点js中的同一模块导出构造函数和一些正常函数?
- 使用jquery在textarea中的颜色代码
- javaES6箭头函数的全新特性
- JavaScript学习-5——异步同步、回调函数
- 什么“返回此”在javascript函数中做什么?
- 为什么我的javascript/jquery代码不能像预期的那样工作?
- 实现浮动广告的代码
- jQuery和AJAX - 使用Ajax添加的对象动态不适用于jQuery函数?