一页上有多个Jquery对话框

我正在使用jquery对话框弹出窗口。 我有多个div(动态创建)需要在单个页面上弹出。 我目前的问题是,当我点击.open时,所有(10)弹出窗口都打开,我怎么才能触发一个?

我的HTML如下:

   

Dialog text and stuff

Dialog text and stuff

我的jquery如下:

   // added .dialog:disaplay:none; to desktop.css $(document).ready(function () { $('a.open').prop('id', function (i) { return '' + (i + 1); }); $(".dialog").dialog({ autoOpen: false, draggable: false, width: "300px", modal: true, buttons: { "Close": function () { $(this).dialog('destroy').remove() } } }); $("#1,#2,#3,#4,#5,#6,#7,#8,#9,#10") .click(function () { alert($(this).attr("id")); $(".dialog").dialog("open"); return false; }); });  

这应该工作(或它的变体)。

 $("#1,#2,#3,#4,#5,#6,#7,#8,#9,#10").click(function () { alert($(this).attr("id")); $(this).next(".dialog").dialog("open"); return false; }); 

我觉得有必要告诉你只使用一个类作为你的点击处理程序

 $(".open").click(function(e) { e.preventDefault(); $(this).next(".dialog").dialog("open"); }); 

如果您不使用ID,则无需使用ID。

如果我正确地阅读您的代码,您正在做的是

 $('.dialog').dialog('open'); 

即你掌握了使用对话框类的所有元素。 当然,这会同时打开所有对话框。 如果你沿着这条线重写你的标记

 

Dialog text and stuff

然后呢

 $('#diaOne').dialog('open');//grab just the dialog bearing the id diaOne. 

我应该怀疑这个伎俩