Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery对话框中显示的Javascript函数_Javascript_Jquery_Html_Jquery Ui_Dialog - Fatal编程技术网

Jquery对话框中显示的Javascript函数

Jquery对话框中显示的Javascript函数,javascript,jquery,html,jquery-ui,dialog,Javascript,Jquery,Html,Jquery Ui,Dialog,我想要一个带有javascript函数的Jquery对话框,该函数显示一个成分列表(成分来自数据库,这就是为什么我在js函数中使用它的原因)。我有一个按钮: <div id="dialog"> //WANT showKeyIngredients() to show up in here, the dialog box </div> <div id="confirm-dialog"> <a href='#' class="buttonsty

我想要一个带有javascript函数的Jquery对话框,该函数显示一个成分列表(成分来自数据库,这就是为什么我在js函数中使用它的原因)。我有一个按钮:

<div id="dialog">
    //WANT showKeyIngredients() to show up in here, the dialog box
</div>
<div id="confirm-dialog">
    <a href='#' class="buttonstyle2" onclick="showKeyIngredients();">
        Browse
    </a>
</div>
很抱歉,这可能是相当混乱的,因为我是jQuery新手,一直在复制和粘贴东西。我甚至不确定这是否可能。我到处找,什么也没找到。我只想在对话框中显示showKeyComponent()函数。html中的onclick根本不会显示在对话框中


我喜欢这里的对话框,但希望我的showKeyComponents()函数显示在其中。并有一个弹出对话框的按钮。

答案非常粗略,很容易回答,但这就是你要找的东西吗?:

$("#dialog").dialog();
$("#dialog").html('<div> Some element with showKeyIngredients returned stuff </di>')
$(“#dialog”).dialog();
$(“#dialog”).html('showKeyComponents返回的某些元素')
更加充实:

您可以用ShowKeyComponents返回的内容替换.html()文本。
(为了简单起见,我删除了所有的对话框设置,它们可以重新添加)

任何您想在对话框主体中显示的内容,只需将其放入段落(

)标记中即可

试试这个:

<div id="confirm-dialog">
  <p>
    <a href='#' class="buttonstyle2" onclick="showKeyIngredients();">
        Browse
    </a>
  </p>
</div>




我在很多地方的网站上也使用过这个对话框。你不需要做任何额外的事情


正在工作。

该对话框只是另一个
div
。如果要在其中插入信息,请在对话框div中选择适当的子元素并附加到该子元素。您需要显示其他代码,例如
showKeyComponents
,以获得更好的答案。
<div id="confirm-dialog">
  <p>
    <a href='#' class="buttonstyle2" onclick="showKeyIngredients();">
        Browse
    </a>
  </p>
</div>
<div id="dialog">
  <p>
    <a href='#' class="buttonstyle2" onclick="showKeyIngredients();">
        Browse
    </a>
  </p>
</div>