Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有一种方法可以获取我父 div 的 id 而不必像下面那样在前面附加“#”?
谢谢
var parentDivId = $(div).closest("div").attr("id"); $("#" + parentDivId).dialog('close');
这将关闭对话框:
$("#" + parentDivId).dialog('close');
这不起作用:
$(parentDivId).dialog('close');
如果我没记错的话,你也许可以这样做:
$(div).parent().dialog('close');
您的变量parentDivId足以完成它,请尝试以下方法:
parentDivId
$('[id="' + parentDivId + '"]').dialog('close');