Hello i在jquery撰写了一些文字,并将之约束在一次点击活动中,但该代码并未通过点击活动启动。 但是,如果将文字放在另一个Java文本功能中,并且把 Java本功能约束在点击事件聆听器上,而该功能无法在点击时执行。
Another thing is that when i bind the script using JavaScript it returns me alert message same number of time as the number of div on which i have clicked i.e. if i click on 3rd div the alert message is shown three times on my page the dom structure is of pdf.js project and this dom is created dynamically i want to get the index of grandchild of pagecontainer2 on which user had clicked following is my script:
<script type="text/javascript">
$(function() {
$(".textLayer > div", "#pageContainer2").click(function () {
var index = $(this).index();
alert("index of div is = " + index);
});
});
</script>
Dom CODE:
<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>