I have written some jquery code to select the div which is grandchild of another div having id pageContainer2 on which user clicked and show a alert message with index value. But the code is node working at all, so please see if i am writing the code wrong or is their any other problem.
Following is my html page code with jquery script :
<script>
$("div#pageContainer2 div.textLayer div").click(function () {
// this is the dom element clicked
var index = $("div").index(this);
alert("index of div is = " + index);
});
</script>
<div id="pageContainer2" >
<canvas id="page2" width="741" height="959"></canvas>
<div class="textLayer">
<div>......some text here....</div>
<div>......some text here....</div>
<div>......some text here....</div>
</div>
</div>
<div id="pageContainer3" >
<canvas id="page3" width="741" height="959"></canvas>
<div class="textLayer">
<div>......some text here....</div>
<div>......some text here....</div>
<div>......some text here....</div>
</div>
</div>
FIDDLE