我是 jQuery 和 java 的新手,我真的很想集中精力创建对话框的多个实例。我在头部使用这个:
<script src="external/jquery/jquery.js"></script>
<script src="jquery-ui.js"></script>
Run Code Online (Sandbox Code Playgroud)
如果我只有 1 个按钮和一个对话框,它就可以工作。但是当我添加另一个时它就停止工作了。我相信这很容易解决,我只是在挣扎。
<h2>subjects</h2>
<button id="opener">maths</button>
<div id="dialog" title="Dialog Title">maths is an important subject.</div> <br>
<button id="opener">english</button>
<div id="dialog" title="Dialog Title">this is also very important</div> <br>
<script>
$( "#dialog" ).dialog({ autoOpen: false });
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
</script>
Run Code Online (Sandbox Code Playgroud)