api用途:获取指定元素的父节点

 

兼容性参考:http://zhangyaochun.iteye.com/blog/1439707

 

 


/*
*_g*
*@inner-function*
*@param id*
*@return {HTMLElemet}*
*@relay on ZYC.lang*
*/
ZYC.dom._g = function(id){
    if(ZYC.lang.isString(id)){
	   return document.getElementById(id);
     } 
     return id;
}

 

 


/*
*getParent --get the parent node of the target element*
*@function*
*@param {HTMLElement|String} element*
*@return {HTMLElement|null}*
*/
ZYC.dom.getParent = function(element){
       element = ZYC.dom._g(element);
       //parentElement ---ie
       //parentNode --ff
       return element.parentElement || element.parentNode || null;
};