Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove attribute title from all HTML elements

I want to compleately wipe the title attribute from all elements inside a html doc. From table, p, img, div etc..

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?

like image 289
Malasorte Avatar asked Aug 27 '26 11:08

Malasorte


2 Answers

Use the attribute selector and select just the elements with the title attribute and not all elements.

$("[title]").removeAttr("title");
like image 104
epascarello Avatar answered Aug 29 '26 02:08

epascarello


The all selector, *, selector should do the trick

$('*').removeAttr('title');
like image 26
David Hedlund Avatar answered Aug 29 '26 00:08

David Hedlund