javascript - How do I know which <li> element was clicked from a <ul>? -
I have & lt; Ul & gt;
, and every & lt; Li & gt; The background of
is 50px * 50px but I want to know which code is
gt; I click on ul, first, second, third. Each & lt; Li & gt;
has an image, therefore, when I ; Li & gt;
another & lt; Div & gt;
, but when I want to change the image I wanted to know, click on which was clicked.
$ ("# ul element"). ("Click", "li", (function () {$ ($ ("# theediv"). $ ("# Thediv") empty (). App ('
gt;' + this Inner HTML + '& lt; / li & gt;'); $ ("# thediv") .FadeIn ("slow");}));
So when I took one Clicking on the image goes to div, but I want to know which index is taken (1,2,3,4,5, etc.).
You can use the following to get the current index in the list
$ (this). Index (); < / Code>
Comments
Post a Comment