I have elements and each element have multiple classes, and I want to define each of these classes to use in jquery..
to explain.. this is the code: http://jsfiddle.net/wUWYs/2/
HTML:
<div class="red row4 col1"></div>
<div class="red row3 col2"></div>
<div class="red row2 col3"></div>
<div class="red row1 col4"></div>
<div class="blue row1 col1"></div>
<div class="blue row2 col2"></div>
<div class="blue row3 col3"></div>
<div class="blue row4 col4"></div>
and this is what I tried to do with jquery:
jQuery:
$(".red").each(function(){
var colNumber = $(this).attr("class");
$(this).hover(
function(){$(".blue."+colNumber).show();},
function(){$(".blue").hide();}
);
});
the main problem that I want when hover red element who have col1 and row4 classes, then the two blue elements will shown, who have col1 and who have row4 ..
problem here:
var colNumber = $(this).attr("class");
how can I define the specific class, and how to make the number variable?