本文介绍了如果条件如何调用对话框? JavaScript的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我知道这对于那些人来说是一个非常简单的问题,但我是初学者,我试图弄清楚如何在if条件中使用带有参数的2个按钮来调用对话框。我的代码不是调用函数只显示警报消息。如果有人可以开导,我会非常感谢谢谢 我尝试过: I know this is a very simple question for those but I am a beginner and I am trying to figure out how to call dialog box with 2 buttons with parameters inside an if condition. my code is not calling function only display alert message. If someone can enlighten I will really appreciate it thank youWhat I have tried:<div id="requirement #2"> <button type="button" id="button4" onclick="StringSearch1()">Search</button></div><script> function StringSearch1() { if (condition) { stayonPage1(val1,val2,val3); // alert("textfield1 " + val1 + " Exists in textfield2 and its corresponding value in text 3 is " + val3) //; //the alert message is working but I want to call the function dialogbox to pop } else { // alert("textfield1 " + val1 + " not Exists in textfield2 and its corresponding value in text 3 is " + val3) } } function stayonPage1(val1,val2,val3){ var dialog = $("textfield1 " + val1 + " Exists in textfield2 and its corresponding value in text 3 is " + val3).dialog({ buttons: { "Apply": function() {alert('you chose yes');}, "Cancel": function() { dialog.dialog('close'); } } }); } </script> 推荐答案 这不会选择任何项目。你需要一个像对话ID一样的div That doesn't select any item. You need something like a div with an id of dialog<div id="dialog" title="Dialog Title">I'm a dialog</div> 然后你做了类似的事情 Then you do something likefunction stayonPage1(val1, val2, val3) { 这篇关于如果条件如何调用对话框? JavaScript的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-31 20:57