html:
<div class="box-one">
<img title="element_a">
<img title="element_b">
<img title="element_c">
<img title="element_d">
</div>
<div class="box-two">
<div id="element_a"></div>
<div id="element_b"></div>
<div id="element_c"></div>
<div id="element_d"></div>
</div>
How can I check (with jQuery) by clicking on an <img>
at "box-one", if there is also a <div>
that machtes with the ID in "box-two"?
Example:
If I click on <img title="element a">
, the <div id="element a">
should be the only one that got an extra class called "found".
My bad try:
$('.box-one img').click(function() {
$(this).each( function(){
var elementTitle = $('.box-one img').prop('title');
var elementTable = $('.box-two div').prop('id');
// this part is a shame, sry 4 that //
if (elementTitle) == (elementTable) {
$(this).addClass("found");
}
});
});