每一天的生活,不再为一点小事悲痛动怒,会安安心心,简简单单,做一些能让自己开心的事。不要过分在意一些人,过分在乎一些事,顺其自然,以最佳的心态应对。
1.事件冒泡:
//取消冒泡
if(e.stopPropagation){
e.stopPropagation();//w3c定义的APIbiaozhun
}else{
e.cancelBubble=true;//兼容IE 6,7,8浏览器
}
2.获取某个元素的CSS属性值:
//获取某个元素的CSS属性值
function getStyle(element,stylename){
if(element.currentStyle){
//IE
return element.currentStyle[stylename];
}else{
//其他浏览器
var computedStyle=window.getComputedStyle(element,null);
return computedStyle[stylename];
}
}
以上这篇javascript兼容性(实例讲解)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。