taking text from title attribute and adding it into a div in jquery
Posted
by ivordesign
on Stack Overflow
See other posts from Stack Overflow
or by ivordesign
Published on 2010-06-02T09:27:43Z
Indexed on
2010/06/02
9:44 UTC
Read the original article
Hit count: 298
jQuery
|attributes
Basically i'm trying to grap the text from the title attribute in a link and show it in a paragaph in another div when a user hovers of the item, and then hide it when the user moves away. so far what i've got is
(function($) {
$.fn.showText = function() {
$(this).hover(
function() {
$(this)
.data('title', $(this).attr('title'))
.removeAttr('title')
.appendTo(".itemDecription p");
},
function() {
$(this).attr('title', $("this").data('title'));
}
);
}
})(jQuery);
//call the plugin
$(function(){
$('.wrapper ul li a').showText();
});
I got the code from somewhere else on stackoverflow, but i just can't seem to get it to work, and help would be much appriciated.
© Stack Overflow or respective owner