Selecting one block in a collection
I have a structure of similar blocks
- all containig a clickable image
- each identified by a unique hidden index
I want to find the value of that index when clicking on the image
The code is something like :
- <div class="bloc">
<p class="enTete">
<img class="modif" src="monImage">
<input type="hidden" value="1" />
</p>
<div class="content">
Contenu
</div>
</div> <!-- End bloc 1 -->
<div class="bloc">
<p class="enTete">
<img class="modif" src="monImage">
<input type="hidden" value="2" />
</p>
<div class="content">
Contenu
</div>
</div> <!-- End bloc 2 -->
<div class="bloc">
<p class="enTete">
<img class="modif" src="monImage">
<input class="index" type="hidden" value="3" />
</p>
<div class="content">
Contenu
</div>
</div> <!-- End bloc 3 -->
How can i write the selector to read the right index when one the image is selected ?
Somethig like : (The '?' means I dont find how to do !!!!)
- $(' ? .modif').click(function() {
test = $(' ? .index').val();
alert(test);
});