I have some code that creates some span tags and each span has its own ID
counter1
counter2
counter4
by its name in the database.
Now I’m trying to reach the value of one of them. So, I tried something like this:
var id = // Any number that have a span.
var Counter = $("#counter" + id).val();
alert(Counter);
But, it’s just showing “NaN”
Change
.val()to.html()to access the innerHtml of an html element..val()selects the value of an html input element as detailed in the API.