I need to disable the title value, so the hover doesn’t show up, and still read its value. According to this StackOverflow question, the following should work:
$("[title]").each(function() {
$this = $(this);
$.data(this, "title", $this.attr("title"));
$this.removeAttr("title");
});
Which does remove the title property, the only problem is, I can’t for the life of me figure out how to read that data value. I know it’s a simple question, but I’d really appreciate the help, the jQuery documentation didn’t help me on this.
What I currently have is: which doesn’t work for some reason.
var description = $(this).find("img").data(this, "title");
The code example you gave could be tidied up a bit with the latest jQuery versions…
You probably want something like this…
This will assign the
titleattribute to the data store of each element with atitleattribute, and then remove thetitleattribute of the element.Then you can read an element’s old
titleattribute with…jsFiddle.