1 2 3 4 5 6 7 8 9 |
$("#mylist li").click(function() { alert(this.id); //WORK ON JAVASCRIPT ONLY 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 alert($(this).attr("value")); }); |
Maybe this helps also Get element Value Name ID – ATTR
Or maybe getting the length of text input