0
$("#dialog-cust-grp,#dialog-cust-nm").dialog({
         open: function(event, ui) {
                 $("a.ui-dialog-titlebar-close").remove();
               },
         bgiframe: true,autoOpen: false,closeOnEscape: false,
         resizable: false,modal: true,show: "drop",hide: "drop",                
         draggable: false,zIndex: 10000,
         buttons: {'Ok': function() {$(this).dialog("close");
                    if (selector is #dialog-cust-nm){
                      alert(“hello....”);
                    }
         }
   });

基于上面的代码,它有两个不同的选择器,即$("#dialog-cust-grp,#dialog-cust-nm")有没有一种方法可以检查调用中实际使用了哪个选择器,.dialog()因为我需要一种方法来做上面这样的事情,即

If (selector is #dialog-cust-nm){
  alert(“hello....”);
}

这可能吗?

4

2 回答 2

2

您可以通过.attr()调用属性值

if ($(this).attr("id") == "dialog-cust-nm") {
   alert(“hello....”);
}
于 2012-10-11T06:36:48.263 回答
0

您可以使用 。is()检查元素是否与选择器匹配。

if ($(this).is("#dialog-cust-nm")){
    alert(“hello....”);
} 
于 2012-10-11T06:48:19.787 回答