zsharp zsharp -4 years ago 153
jQuery Question

How to get element value in jQuery

Why is it not returning value in 'li'? What am i doing wrong?

$("#list li").click(function() {
var selected = $(this).val();

Answer Source

Did you want the HTML or text that is inside the li tag?

If so, use either:




The val() is for form fields only.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download