Malasorte Malasorte - 3 months ago 8
HTML Question

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?

Answer

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

$("[title]").removeAttr("title");