Coding⏱️ 1 min read📅 2026-05-31

How to Fix: $(this).val() not working to get text from span using jquery

The issue is due to the span element not having a value attribute, so .val() returns undefined. Use .text() instead.

Quick Answer: Use .text() instead of .val() to get the text content of the span element.

Giving this html, i want to grab "August" from it when i click on it:

August

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database