我正在尝试在模式窗口中选择输入字段的值。
function title()
{
$('a.title_filestock').click(function(e) {
e.preventDefault();
var data = $(this).children('img').attr('rel');
var active = $(this).next('a.filestock_preview');
var value = active.text();
new VayesModal('<label for=Display Name"><input id="'+data+'" type="text" size="12" value="'+$.trim(value)+'" />', { modal: true, modalOpacity: '.5', title: 'Type File Display Name', titleClass: 'anim warning', buttons: [{id: 0, label: 'Save', val: 'Y', btnClass: 'btn-success'}, {id: 1, label: 'Cancel', val: 'N', btnClass: 'btn-danger'}], callback: function(val) { if(val == 'Y') { alert($('input[id="'+data+'"]').val()); active.text('new string'); } else return false; }});
});
}
title();
“新字符串”应该是$('input[id="'+data+'"]').val()
,但它返回未定义。我可能会犯错?