Why is it not returning value in 'li'? What am i doing wrong?
$("#list li").click(function() {
var selected = $(this).val();
alert(selected);
})
jquery
Why is it not returning value in 'li'? What am i doing wrong?
$("#list li").click(function() {
var selected = $(this).val();
alert(selected);
})
Best Solution
Did you want the HTML or text that is inside the
li
tag?If so, use either:
or:
The
val()
is for form fields only.