Struggled to adequately describe the scenario in the question. I’m trying to learn jQuery so there will no doubt be a bundle of mistakes in what I already have.
This is the jQuery code I have thus far.
$(document).ready(function() {
$('a.x', $('#innerlayout')).hover(
function () {
var path = $(this).attr('rel');
var text = $(this).attr('title');
$(this).append($("<p class='revealer'><img src='"+path+"' /><br />"+text+"</p>"));
$('p.revealer').hide().fadeIn(500);
},
function () {
$(this).find('p:last').hide();
$(this).removeClass('x').addClass("revealed");
}
);
$('a.revealed', $('#innerlayout')).hover(
function() {
$(this).find('p').show();
},
function() {
$(this).find('p').hide();
}
);
});
and the HTML is basically
<a class="x" href="javascript:void(0)" rel="image1.jpg" title="Image">
<img src="icon.jpg" width="40" height="40" alt="Icon" />
</a>
My previous incarnation of this used remove() to remove the p tag on mouseout and worked okay. I wanted to try and change it so that the content was just hidden, and the class changed so that if mousenter occurred again it would just show the existing content. Instead I find that it still appends the content again and stacks up on each enter/out. Can anyone suggest where I’m going wrong?
I ended up using this solution which provided the functionality I sought.
with this HTML
Originally the title attribute was used to supply the var text but I found I occasionally need to include html in here and so adopted this approach.