A while back I set up the following to have a very simple image swap using jQuery. Now that the site needs to expand, however, I cannot figure out the actual value of the $(this) selector. I thought it would be $(‘.gallery li img’) but that doesn’t seem to be the case. It’s been a while since I’ve looked at this code, and I’m entirely lost.
$('.gallery li img').hover(function() {
var $gallery = $('.gallery li img').parents('.gallery');
var cur_img = $(this).attr('src').replace('thumb/', '');
$('.main-img', $gallery).attr('src', cur_img);
});
I don’t need a better means to set up a gallery, what I have works fine (although comments are appreciated as always) I just need to figure out the value of $(this) in the given circumstance.
Isn’t the (this) in jQuery just a self-referential? Meaning, basically, “whatever is currently selected or focussed on?” (Sorry – don’t know how to comment, or I’d do that instead.)
Looking at your code, it looks like it’s just replacing the current image’s source with the prefixed path “thumb/”.