我已经定义了 afunction用于在 a 中显示一些html内容jqueryui dilaog:
function ui_window(title, dialogWidth, content,buttons,className)
{
$('<div id="window">').html(content).
dialog({
title: title,
show: 'drop',
hide: 'drop',
width: dialogWidth,
buttons: buttons,
close: function (ev, ui) { $(this).remove(); },
position: { my: 'center', at: 'center', of: window }
}
).addClass(className);
return false;
}
这是另一个function调用上述内容的javascript function:
function checkForValidCommand()
{
var content = getInnerHTML("#checkForValidCommand");
var myFunc = function ()
{
var pensionerID = $('#txtID').val();
alert(pensionerID);
$(this).dialog('destroy');
}
else
$('#txtID').focus();
}
var buttons = [{ text: 'OK', click: myFunc}];
ui_window("Pensioner", 410, content, buttons);
}
当我checkForValidCommand第一次调用“”并input进入value唯一textbox并按确定时,我会收到一个警报,其中包含textbox. 然后,当我function再次调用并按 OK 而不在其中输入任何内容时,textbox我仍然得到alert 旧的value. 我的代码有什么问题?
编辑:如果您想查看,这是 html 内容:
<table>
<tr>
<td align="right">
<label>
Insert the pensioiner's ID:
</label>
</td>
<td>
<input id="txtID" type="text" onkeydown="return onlyNumbers(event);" maxlength="8"/>
</td>
</tr>
</table>