我想在.row中找到索引.col 当我点击.option时,它应该在.row
中给我.col的位置<div class=“row”>
<div class=“col”>
<div class=“option”>click (return 0)</div>
</div>
</div>
<div class=“row”>
<div class=“col”>
<div class=“option”>click 2 (return 1)</div>
</div>
</div>
谁能告诉我怎么样?
答案 0 :(得分:0)
为其设置点击监听器
$('.option').click(function (event) {
alert($(this).index()); // the index was $(this).index()
});
答案 1 :(得分:0)
<div class=“row”>
<div class=“col”>
<div class=“option” onclick="myFunction(0)">click (return 0)</div>
</div>
</div>
<div class=“row”>
<div class=“col”>
<div class=“option” onclick="myFunction(1)">click 2 (return 1)</div>
</div>
</div>