Javascript判斷一個(gè)元素(對(duì)象)是否為另一個(gè)元素的子元素
發(fā)布時(shí)間:2010/7/8 10:58:58 作者: 閱讀:1301
廣告:
/*判斷是否子對(duì)象*/
function isParent(obj,pobj)
{
/*jquery用法: $("H1").attr("tagName")*/
while (obj != undefined && obj != null && obj.tagName.toUpperCase() != 'BODY')
{
if (obj == pobj)
return true;
obj = obj.parentNode;
}
return false;
}
引用:var flag = isParent(event.toElement, $("#boxindex")[0]); /*重要,取得鼠標(biāo)事件event.toElement*/
廣告:
相關(guān)文章