如下,假设我在 A.html 中有一个点击按钮来打开一个 ui 对话框,该对话框会将 B.html 作为内容加载。
那么,如果我想在用户单击对话框上的“确定”按钮后获取 B.html 中 id=inputName 的值,我该怎么办?我总是得到“未定义”。
抱歉,这可能是一个愚蠢的问题,因为我是 jQuery 新手。如果你能帮助我,我会非常感激。
一个.html
$(function(){
$('#name').click(function(){
var aaa = window.parent.$.dialog({
buttons: {
'ok': function(){
//get the value from B.html(ex.the value which id=inputName)
$aaa.dialog('close');
}
}
});
var link = 'B.html';
aaa.load(link);
aaa.dialog('open')
});
}); //jquery code
<div>
<input type="button" value="input your name" id='name'>
</div> //html code
B.html
<input type="text" name="inputName" id="inputName"/>