Mih*_*nca 0 javascript jquery jquery-ui modal-dialog
我有以下代码:
<script type="text/javascript">
$( "#form_div" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true
});
</script>
<div id="form_div" title="Trimite-ne un mesaj!">
<form name="htmlform" method="post" action="html_form_send.php">
<table width="450px">
</tr>
<tr>
<td valign="top">
<label for="first_name">Nume*</label>
</td>
<td valign="top">
<input type="text" id="first_name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Email *</label>
</td>
<td valign="top">
<input type="text" id="email" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="message">Mesaj: *</label>
</td>
<td valign="top">
<textarea id="message" maxlength="1000" cols="25" rows="6"></textarea>
</td>
</tr>
</table>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
问题是,在单击按钮并显示为模式对话框之前,页面加载时仍会显示表单而不是隐藏.我在页面中加载了最新的JQuery和JQuery-UI.知道问题可能是什么?
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet"
href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
function OpenModal()
{
$( "#form_div").dialog();
$("#btnDisp").hide();
}
</script>
</head>
<body>
<div id="form_div" title="Trimite-ne un mesaj!" style="display:none;">
<form name="htmlform" method="post" action="html_form_send.php">
<table width="450px">
</tr>
<tr>
<td valign="top">
<label for="first_name">Nume*</label>
</td>
<td valign="top">
<input type="text" id="first_name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Email *</label>
</td>
<td valign="top">
<input type="text" id="email" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="message">Mesaj: *</label>
</td>
<td valign="top">
<textarea id="message" maxlength="1000"
cols="25" rows="6"></textarea>
</td>
</tr>
</table>
</form>
</div>
<input id="btnDisp" type="button" onclick="OpenModal();"
value="display the form"/>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
请看这个工作完美......