Using jQuery, how would I go about changing the style of the <span> element, when the image is hovered in each post?
Here is an example of the HTML structure:
<img src="#" class="postone">
<div class="description">
<p><span class="postone"> text </span> other text </p>
</div>
<img src="#" class="posttwo">
<div class="description">
<p><span class="posttwo"> text </span> other text </p>
</div>
Here is the jQuery I have already:
$(document).ready( function(){
$("img").hover( function(){
var className = $("this").attr('class');
$("span" + className).css("color", "#fff");
});
});
$("span" + className)should be$("span." + className)$("this")should be$(this), yes, but really – use CSS.