Jquery ui jquery使用:last和val()
我试图在我的机器上运行代码,我使用的方法是低于或 你知道为什么那个代码在我的机器上不起作用吗。Firebug帮不了我,我也解决不了这个问题。我想我需要另一双眼睛:((( 在firebug的控制台选项卡中,我没有收到任何错误消息。问题是,在我按下保存按钮后,我无法从对话框中获取该输入的值。$('input:last').val()似乎为空Jquery ui jquery使用:last和val(),jquery-ui,Jquery Ui,我试图在我的机器上运行代码,我使用的方法是低于或 你知道为什么那个代码在我的机器上不起作用吗。Firebug帮不了我,我也解决不了这个问题。我想我需要另一双眼睛:((( 在firebug的控制台选项卡中,我没有收到任何错误消息。问题是,在我按下保存按钮后,我无法从对话框中获取该输入的值。$('input:last').val()似乎为空 <!DOCTYPE html> <html lang="en"> <head> <meta charset="
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Dialog - Modal form</title>
<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" >
jQuery(function($) {
$('.helpDialog').hide();
$('.helpButton').each(function() {
$.data(this, 'dialog',
$(this).next('.helpDialog').dialog({
autoOpen: false,
modal: true,
width: 300,
height: 250,
buttons: {
"Save": function() {
alert($('.helpText:last').val());
$(this).dialog( "close" );
},
Cancel: function() {
$(this).dialog( "close" );
}
}
})
);
}).click(function() {
$.data(this, 'dialog').dialog('open');
return false;
});
});
</script>
</head>
<body>
<span class="helpButton">Button</span>
<div class="helpDialog">
<input type="text" class="helpText" />
</div>
<span class="helpButton">Button 2</span>
<div class="helpDialog">
<input type="text" class="helpText" />
</div>
<span class="helpButton">Button 3</span>
<div class="helpDialog">
<input type="text" class="helpText" />
</div>
<span class="helpButton">Button 4</span>
<div class="helpDialog">
<input type="text" class="helpText" />
</div>
<span class="helpButton">Button 5</span>
<div class="helpDialog">
<input type="text" class="helpText" />
</div> </body>
jQueryUI对话框-模态表单
jQuery(函数($){
$('.helpDialog').hide();
$('.helpButton')。每个(函数(){
$.data(此“对话框”,
$(this).next('.helpDialog').dialog({
自动打开:错误,
莫代尔:是的,
宽度:300,
身高:250,
按钮:{
“保存”:函数(){
警报($('.helpText:last').val());
$(此).dialog(“关闭”);
},
取消:函数(){
$(此).dialog(“关闭”);
}
}
})
);
})。单击(函数(){
$.data(此“对话框”).dialog(“打开”);
返回false;
});
});
按钮
按钮2
按钮3
按钮4
按钮5
参考
为了在保存时显示文本,我已将行警报($('.helpText:last').val();
修改为此警报($('.helpText',this.val());
我又增加了一个对fiddler的依赖
现在它的工作如预期
HTML:
您的计算机上发生了什么?弹出窗口不显示?此外,firebug控制台中是否有任何错误。您是否将所有依赖项都放在正确的位置?
<span class="helpButton">Button</span>
<div class="helpDialog">
<input type="text" class="helpText" />
</div>
<span class="helpButton">Button 2</span>
<div class="helpDialog">
<input type="text" class="helpText" />
</div>
<span class="helpButton">Button 3</span>
<div class="helpDialog">
<input type="text" class="helpText" />
</div>
<span class="helpButton">Button 4</span>
<div class="helpDialog">
<input type="text" class="helpText" />
</div>
<span class="helpButton">Button 5</span>
<div class="helpDialog">
<input type="text" class="helpText" />
</div>
jQuery(function($) {
$('.helpDialog').hide();
$('.helpButton').each(function() {
$.data(this, 'dialog',
$(this).next('.helpDialog').dialog({
autoOpen: false,
modal: true,
width: 300,
height: 250,
buttons: {
Save: function() {
alert($('.helpText', this).val());
$(this).dialog( "close" );
},
Cancel: function() {
$(this).dialog( "close" );
}
}
})
);
}).click(function() {
$.data(this, 'dialog').dialog('open');
return false;
});
});