我想在是-否逻辑中触发对话框模式消息脚本。
目前它在 onclick
事件中工作。示例:http://jqueryui.com/dialog/#modal-message
如果我的逻辑正确,我希望它自动执行(无需任何点击)。
示例:
如果逻辑为真则执行
<script>
$(function() {
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
</script>
有什么想法吗?
最佳答案
<script>
$(function() {
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
if ( condition )
$( "#dialog-message").dialog('open');
});
</script>
这就是带条件调用它的方式。
关于javascript - 触发 JavaScript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25603893/