Hi All,
I am stuck with a problem here, please help. What my requirement is to get the index value of the div clicked. Have 2 lists, and i need to call a function doSomething(); only when the user clicks the first div set. Is there anyway that i can achieve it.
The scripts and HTML is as follows
$(document).ready(function() {
$(".list-wrapper li").click(function() {
var index = $(".list-wrapper div").index(this);
alert(index);
});
});
<div class="list-wrapper">
<ul>
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
</ul>
</div>
<div class="list-wrapper">
<ul>
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
</ul>
</div>
Please help...