我已添加如下的点击事件,并想检查目标是否有特定的父元素。
$(document).click(function(event){
// Check here if target has specific parent for example -> #parent
});
如何完成这个任务?
this
不是字面上的DOM元素(而不是jquery对象)吗?$(document).click(function(event){ console.log( $(this.parentNode) ); });
- That Realty Programmer Guy