我在JqueryUI中使用accordion函数。在每个项目中都有一个带有名称的提交按钮。名称是对话框窗口中我需要的ID。当我点击提交按钮时,使用此功能
$( ".opener" ).click(function() {
console.log( $(this).attr("name"));
$( "#dialog-confirm" ).dialog( "open" );
});
在我的控制台日志中,我现在看到了正确的ID。但是在对话框窗口中,我无法获得此ID。这是对话窗口
$(function() {
$( "#dialog-confirm" ).dialog({
autoOpen: false,
show: {
effect: "fade",
duration: 500
},
hide: {
effect: "fade",
duration: 200
},
resizable: false,
height:180,
modal: true,
buttons: {
"Aannemen": function() {
$( this ).dialog( "close" );
alert('ID IS'); << this is where i want the id
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
那么我怎样才能获得剧本这个位置的id:警告('ID IS');
答案 0 :(得分:1)
var name;
$( ".opener" ).click(function() {
name =$(this).attr("name");
$( "#dialog-confirm" ).dialog( "open" );
});
$(function() {
$( "#dialog-confirm" ).dialog({
autoOpen: false,
show: {
effect: "fade",
duration: 500
},
hide: {
effect: "fade",
duration: 200
},
resizable: false,
height:180,
modal: true,
buttons: {
"Aannemen": function() {
$( this ).dialog( "close" );
alert(name); << this is where you get the id
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});