Created
July 24, 2013 10:17
-
-
Save csharpforevermore/6069427 to your computer and use it in GitHub Desktop.
In a HTML unordered list, get the list item that was clicked (UL > LI) Code copied from http://stackoverflow.com/questions/3545341/jquery-get-the-id-value-of-li-after-click-function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("ul.nav li").click(function () { | |
alert(this.id); // id of clicked li by directly accessing DOMElement property | |
alert($(this).attr('id')); // jQuery's .attr() method, same but more verbose | |
alert($(this).html()); // gets innerHTML of clicked li | |
alert($(this).text()); // gets text contents of clicked li | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you are unbelievable.