jQuery: How to determine which <li> tag was clicked?

Posted by user337909 on Stack Overflow See other posts from Stack Overflow or by user337909
Published on 2010-05-11T05:04:07Z Indexed on 2010/05/11 5:14 UTC
Read the original article Hit count: 122

Filed under:

I am creating a form with 5 lines of text, and each text I am allowing the user to select if they want the text to be centered, left, or right justified. I have a unnumbered list with list elements x5.

<li><img src="images/justify_left.png" alt="left" /><span>Justify Left</span></li>
<li><img src="images/justify_center.png" alt="center" /><span>Justify Left</span></li>
<li><img src="images/justify_right.png" alt="right" /><span>Justify Left</span></li>

Each of the 5 set of <li> items refers to its respective line.

With jQuery, how would I go about determining which of the 15 <li> items did the user select so that I can correspond the proper justification as a post method?

© Stack Overflow or respective owner

Related posts about jQuery