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附加到表中,这不是你想要的。

更多相关文章

  1. 代码点火-如何从控制器返回Json响应
  2. 是否可以从节点js中的同一模块导出构造函数和一些正常函数?
  3. 使用jquery在textarea中的颜色代码
  4. javaES6箭头函数的全新特性
  5. JavaScript学习-5——异步同步、回调函数
  6. 什么“返回此”在javascript函数中做什么?
  7. 为什么我的javascript/jquery代码不能像预期的那样工作?
  8. 实现浮动广告的代码
  9. jQuery和AJAX - 使用Ajax添加的对象动态不适用于jQuery函数?

随机推荐

  1. 别再问我Python打包成exe了!(终极版)
  2. Scrapy框架的使用之Item Pipeline的用法
  3. 【SQL刷题系列】:leetcode177 Nth Highest
  4. 【机器学习笔记】:从零开始学会逻辑回归(一
  5. 5、Shell命令脚本
  6. 你知道Jupyter notebook还可以用来做 “
  7. 【机器学习笔记】:大话线性回归(一)
  8. 【机器学习笔记】:逻辑回归实战练习(二)
  9. 分布式爬虫的部署之Scrapyd分布式部署
  10. Python操作Redis,你要的都在这了!