IE:可以应用获取惯例属性的办法来获取自定义属性,也可以应用getAttribute()获取自定义属性
Firefox:只能应用getAttribute()获取自定义属性.
解决办法:同一经由过程getAttribute()获取自定义属性
PS:在 IE7 及更低版本的IE浏览器中,应用 setAttribute()办法设置 class 和 style 属性是没有效不雅的,固然 IE8 解决了这个bug,但照样不建议应用。
拜访XMLHTTPRequest对象
removeAttribute()办法
removeAttribute()可以移除 HTML 属性。
PS:IE6 及更低版本不支撑 removeAttribute()办法。
跨浏览器事宜Event对象
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- <style type="text/css">
- #drop{
- width: 300px;
- height: 200px;
- background-color: #ff0000;
- padding: 5px;
- border: 2px solid #000000;
- }
- #item{
- width: 100px;
- height: 100px;
- background-color: #ffff00;
- padding: 5px;
- margin: 20px;
- border: 1px dashed black;
- }
- *[draggable = true]{
- -moz-user-select: none;
- -webkit-user-select: none;
- cursor: move;
推荐阅读
【技巧沙龙】AI开辟者拭魅战营-7分钟打造1个定制技能。7月22号,我们等你一路! 这周工作太忙,本来想更把 Attention tranlsation 写出来,但一向抽不出时光,等后面有时光再来写。我们这>>>详细阅读
本文标题:JavaScript操作DOM的那些坑
地址:http://www.17bianji.com/lsqh/36299.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示