使用JQuery获取<div>的内容

时间:2016-03-13 07:27:59

标签: jquery html

我使用过JQuery插件DialogExtend link

在按钮上单击对话框正在打开。我有一个带有一些内容的div标签。如何将该div的内容加载到以下脚本中(代替第3行)

$(function(){
 $("#my-button").click(function(){
  $("<div>This is content</div>")
    .dialog({ "title" : "My Dialog" })
    .dialogExtend({
      "maximizable" : true,
      "dblclick" : "maximize",
      "icons" : { "maximize" : "ui-icon-arrow-4-diag" }
    });
 });

});

html内容想要加载到该行:

<div id="dialog" title="Basic dialog">
  <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p></div>

我对jQuery了解不多,我只根据需要使用插件。

2 个答案:

答案 0 :(得分:1)

试试这样:

<pre class="brush: js;">

答案 1 :(得分:0)

在此Fiddle 你可以看到你的javascript(jquery)代码没问题且工作正常。

也许您不了解如何将其与html绑定,因此请注意 html

<div id="dialog" title="Basic dialog">
 <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p></div> 
<button id="my-button">Button</button>

还要检查资源文件(jquery&amp; jquery UI)

相关问题