Giving this html, i want to grab “August” from it when i click on it:
<span class="ui-datepicker-month">August</span>
i tried
$(".ui-datepicker-month").live("click", function () {
var monthname = $(this).val();
alert(monthname);
});
but doesn’t seem to be working
Instead of
.val()use.text(), like this:Or in jQuery 1.7+ use
on()asliveis deprecated:.val()is for input type elements (including textareas and dropdowns), since you’re dealing with an element with text content, use.text()here.