ホバー時にリンクの「alt」を出力しようとしています。(テキストは#container
divに表示されています)。
これは私がこれまで試してきたことです(うまくいきません):
より良いアイデアがあれば、提案してください。
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/