`

Chome中text-decoration值为initial问题(设置为none无效)

阅读更多
本人做页面设计器开发,需要保存页面元素属性,近期发现偶有text-decoration属性值保存为initial,以致在IE中读取数据时报属性设置异常的脚本错误,经查发现是因为使用谷歌浏览器(Chrome)进行属性设置时,若是把text-decoration值设置为none,就会返回initial值,即:

element.style.textDecoration = 'none';
alert(element.style.textDecoration);
  //return "initial"

因此,若是要消除下划线,应改为以下写法,则可实现浏览器属性兼容:

element.style.textDecoration = '';
alert(element.style.textDecoration);
  //return "none"
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics