gpt4 book ai didi

jquery - 如何使 jQuery 对话框仅在单击按钮后才显示?

转载 作者:行者123 更新时间:2023-12-01 03:56:54 25 4
gpt4 key购买 nike

此代码来自 jQuery 网站上模态确认的演示。

<script type="text/javascript">
$(function() {
$("#dialog").dialog({
bgiframe: true,
resizable: false,
height:140,
modal: true,
overlay: {
backgroundColor: '#000',
opacity: 0.5
},
buttons: {
'Yes': function() {
$(this).dialog('close');
},
'No': function() {
$(this).dialog('close');
}
}
});
});
</script>



<div class="demo">

<div id="dialog" title="Empty the recycle bin?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>

<!-- Sample page content to illustrate the layering of the dialog -->
<div class="hiddenInViewSource" style="padding:20px;">
<p>Sed vel diam id libero <a href="http://example.com">rutrum convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies neque, sit amet auctor elit eros a lectus.</p>
<form>
<input value="text input" /><br />
<input type="checkbox" />checkbox<br />
<input type="radio" />radio<br />
<select>
<option>select</option>
</select><br /><br />
<textarea>textarea</textarea><br />
</form>
</div><!-- End sample page content -->

</div><!-- End demo -->

<div class="demo-description">

<p>Confirm an action that may be destructive or important. Set the <code>modal</code> option to true, and specify primary and secondary user actions with the <code>buttons</code> option.</p>

</div><!-- End demo-description -->

谁能告诉我如何在我按下按钮后才能制作这个节目?现在,它在加载后立即自动显示在页面中。

最佳答案

在页面中添加按钮,并在按钮的点击事件中添加代码。

<script type="text/javascript">
$(function() {
$("#button").click(function(){
$("#dialog").dialog({
bgiframe: true,
resizable: false,
height:140,
modal: true,
overlay: {
backgroundColor: '#000',
opacity: 0.5
},
buttons: {
'Yes': function() {
$(this).dialog('close');
},
'No': function() {
$(this).dialog('close');
}
}
});
});
});
</script>

在 HTML 中

<input type='button' value="click" id="button"/>

关于jquery - 如何使 jQuery 对话框仅在单击按钮后才显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1413147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com