Hi,
I have a
<span id="test">5</span>
and I wand to get its value, 5. And I want to change that value. how do I realize that.
Hi,
I have a
<span id="test">5</span>
and I wand to get its value, 5. And I want to change that value. how do I realize that.
$('#test').text(); // Gets
$('#test').text('hello'); // Sets
Took about 10 seconds to get into the documentation http://jquery.com and search for "text" and read it...
To get it, you probably want the number, so get the .text()
and parse it with parseInt()
, like this:
var val = parseInt($("#test").text(), 10);
To set it just pass the value to .text()
, like this:
$("#test").text(newVal);