Hi,
I’m starting to play with JS/JQuery and I don’t know how to get the name af an anchor. I have a list of img faces and when hovering them, I want to display a random quotation
Here is the html
<div id="faces">
<ul>
<li><a href="#" name="stalin"><img src="../images/img1.gif" width="50" height="58" /></a></li>
<li><a href="#" name="churchill"><img src="../images/img2.gif" width="50" height="58" /></a></li>
</ul>
</div>
<div id="quotation"> </div>
And the JQuery
$(document).ready(function(){
var churchill = [
"churchill quotation 1",
"churchill quotation 2",
"churchill quotation 3"
];
var stalin = [
"stalin quotation 1",
"stalin quotation 2",
"stalin quotation 3"
];
$("#faces li a").hover(function(){
var selected = a[name];
var randomQuotation = selected[ Math.floor( Math.random() * selected.length )];
$("#quotation").append(randomQuotation);
$("#quotation").slideToggle('slow');
},function(){
$("#quotation").hide('slow');
$("#quotation").empty();
});
});
var selected = xxx; I’d like to get churchill or stalin there, correponding to the img hover <a href=“#” name=“stalin”>
Any idea?
Thanks