摘要:
function stopPropagation(e){ e=window.event||e; if(document.all){ e.cancelBubble=true; }else{ e.stopPropagation(); }}用法:document.getElementsByTagName("li")[0].onclick=function(e){ alert("li"); stopPropagation(e);} 阅读全文
摘要:
function getEventTarget(e){ e=window.event||e; return e.srcElement||e.target;} 阅读全文
摘要:
function setAlphaOpacity(elm,value){ elm=typeof elm=="string"?document.getElementById(elm):elm; if(document.all){ //IE elm.style.filter='alpha(opacity='+value+')'; }else{ //FF elm.style.opacity=value/100; }} 阅读全文
摘要:
找下一兄弟节点的兼容问题:FF会将空白、换行等文本信息也当做childNodes中的一员,而IE则会忽略它们,只将DOM节点当做是childNodes的一员。function getNextNode(node){ node=typeof node=="string"?document.getElementById(node):node; var nextNode=node.nextSibling; if(!nextNode)return null; if(!document.all){ //FF不识别document.all while(true){ if(nextNode 阅读全文
摘要:
1. JS 工具函数http://www.cnblogs.com/manong13/archive/2012/03/01/2375059.html2. JS 兼容问题http://www.cnblogs.com/manong13/archive/2012/03/01/2375060.html3. JS 编程思想http://www.cnblogs.com/manong13/archive/2012/03/01/2375061.html 阅读全文
摘要:
输入:函数名function addLoadEvent(func){ var oldonload=window.onload; if("function"!=(typeof window.onload)){ window.onload=func; }else{ window.onload=function(){ oldonload(); func(); } }} 阅读全文
摘要:
1. 添加。输入:元素,类名 function addClass(elm,newClass){ var classes = elm.className.split(' '); var classIndex=hasClass(elm,newClass); if(classIndex==-1)classes.push(newClass); elm.className = classes.join(' '); } 2. 查找。输入:元素,类名 返回:indexfunction hasClass(elm,className){ var classes = elm.... 阅读全文