主题:
3024-night
ambiance-mobile
ambiance
base16-dark
blackboard
cobalt
eclipse
erlang-dark
lesser-dark
mbo
mdn-like
midnight
monokai
neat
neo
night
paraiso-dark
pastel-on-dark
rubyblue
solarized
the-matrix
tomorrow-night-eighties
vibrant-ink
新窗口
视图:
左侧面板
HTML
CSS
JS
预览
F11(全屏显示选中的编辑器)
查看更多帮助信息
相关文章:
jQuery.removeAttr() 函数详解
代码类型:
默认(HTML/CSS/JS)
HTML混合(单页)
PHP
Java
C#
C++
C
SQL
杂项:
启用CSS/JS语法检查
监测脚本运行错误
禁止库文件重复
文档类型:
HTML5
HTML 4.01 Strict
HTML 4.01 Transitional
HTML 4.01 Frameset
XHTML 1.0 Strict
XHTML 1.0 Transitional
XHTML 1.0 Frameset
无
JS库文件:
无
jQuery 1.11.1
jQuery 2.1.1
jQuery 1.10.2
jQuery 1.9.1
jQuery 1.8.3
jQuery 1.7.2
jQuery 1.6.4
jQuery 1.5.2
jQuery 1.4.4
jQuery 1.3.2
jQuery 1.2.6
手动添加:
jQuery 1.11.1
<div id="n1"> <img id="n2" data-id="12" alt="站点名称" title="CodePlayer" src="/static/upload/image/info.png" > <img id="n3" data-id="15" alt="站点logo" title="专注于编程开发技术分享" src="/static/upload/image/js-confirm-close-window-1.png" > </div>
var $imgs = $("img"); // 移除所有img元素的data-id属性 $imgs.removeAttr("data-id"); var $n2 = $("#n2"); var $n3 = $("#n3"); document.writeln( $n2.attr("data-id") ); // undefined document.writeln( $n3.attr("data-id") ); // undefined // 从jQuery 1.7开始,可以同时移除alt和title属性 // 在jQuery 1.6之前的某些版本中,属性名称包含空格会抛出错误"Uncaught InvalidCharacterError: The string contains invalid characters. " // 在jQuery 1.6.x中,属性名称包含空格,不会抛出错误,而是忽略掉本次移除操作 $imgs.removeAttr("alt title"); document.writeln( $n2.attr("alt") ); // undefined (站点名称){小括号内表示在jQuery 1.6.x中的输出内容,下同} document.writeln( $n2.attr("title") ); // undefined (CodePlayer) document.writeln( $n3.attr("alt") ); // undefined (站点logo) document.writeln( $n3.attr("title") ); // undefined (专注于编程开发技术分享)