Skip to content

Instantly share code, notes, and snippets.

@joshje
Created April 30, 2012 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshje/2560220 to your computer and use it in GitHub Desktop.
Save joshje/2560220 to your computer and use it in GitHub Desktop.
Reveal title attribute within innerHTML of time elements
// Uncompressed:
(function() {
var els = document.querySelectorAll('[title]');
for (var i=0,len=els.length;i<len;++i) {
var el = els[i];
if (el.title!='') {
el.innerHTML+=' <span style="background:#EEE;color:#333;padding:2px;font-weight:normal;font-style:normal">'+el.title+'</span>';
el.removeAttribute('title');
}
}
})();
//Bookmarklet:
javascript:(function(){for(var a=document.querySelectorAll("[title]"),b=0,c=a.length;b<c;++b){var d=a[b];""!=d.title&&(d.innerHTML+=' <span style="background:#EEE;color:#333;padding:2px;font-weight:normal;font-style:normal">'+d.title+"</span>",d.removeAttribute("title"))};})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment