对应文档操作,我们最基本的原型还是获取到指定的DOM元素

 

 

/*
*g-get the dom element by id*
*@function*
*@param {string||HTMLElement} id*
*@return {HTMLElement||null} 
*@remark --if not find will return null or if the param is not Legal will return the param*
*/
ZYC.dom.g = function(id){
   if(!id){
      //!null !"" !undefined ----true
      return null;
   }
   if('string' == typeof id || id instanceof String){
      return document.getElementById(id);
   }else if(id.nodeName && (id.nodeType ==1 || id.nodeType == 9)){
      //nodeType ==1  Element
      //nodeType == 9 Document
      return id;
   }
   return null;
}