【发布时间】:2012-07-24 11:52:24
【问题描述】:
我有这段代码,它制作了一个带有多个输入的精美 jQuery 警报框:
//jConfirm( message, [title, callback] )
$('#buttonNew').click(function(){
jConfirm('<form><input id="postTitle" type="text"/><br/><textarea id="postBody"></textarea></form>', 'New Post',
function(r){if(r==true){
alert($('#postTitle').val()); //Expecting the input value but getting "undefined"
}
});
})
当我尝试使用输入到输入中的值(例如使用 alert() 进行测试,如上所示)时,我得到“未定义”。如何从回调函数中访问注入的 HTML 输入的这些值?
【问题讨论】:
标签: jquery