I want to compleately wipe the title attribute from all elements inside a html doc. From table, p, img, div etc..
我想完全擦除html doc中所有元素的title属性。从表,p,img,div等。
Currently I do this:
目前我这样做:
$(document).ready(function(){
$("a").removeAttr("title");
$("img").removeAttr("title");
$("div").removeAttr("title");
// and so on
// and so on
// and so on
});
Is there a more elegant way to do this? Without selecting individual elements?
有没有更优雅的方式来做到这一点?没有选择个别元素?
3 个解决方案
#1
5
Use the attribute selector and select just the elements with the title attribute and not all elements.
使用属性选择器并仅选择具有title属性而不是所有元素的元素。
$("[title]").removeAttr("title");
#2
5
The all selector, *
, selector should do the trick
all选择器,*,选择器应该可以解决问题
$('*').removeAttr('title');
#3
3
You can simply do this using All Selector (“*”)
:
您可以使用All Selector(“*”)简单地执行此操作:
$("*").removeAttr("title");
#1
5
Use the attribute selector and select just the elements with the title attribute and not all elements.
使用属性选择器并仅选择具有title属性而不是所有元素的元素。
$("[title]").removeAttr("title");
#2
5
The all selector, *
, selector should do the trick
all选择器,*,选择器应该可以解决问题
$('*').removeAttr('title');
#3
3
You can simply do this using All Selector (“*”)
:
您可以使用All Selector(“*”)简单地执行此操作:
$("*").removeAttr("title");