I am trying to output the link's "alt" on hover. (Text is showing up in #container
div).
This is what i have been trying so far (it doesnt work):
If you have any better ideas, please suggest.
HTML
<div><a href="#" class="heroes" alt="necromancer">Icon</a></div>
<div><a href="#" class="heroes" alt="witch">Icon</a></div>
<div><a href="#" class="heroes" alt="barbarian">Icon</a></div>
<div><a href="#" class="heroes" alt="troll">Icon</a></div>
<div id="container"></div>
JS:
$('.container').hover(function() {
var hero = $(this).attr('alt');
$('#container').text(hero);
}, function() {
$('#container').text("");
});
JSFIDDLE: http://jsfiddle.net/XDky6/