Reputation: 3587
I have an input, that you can increment up or down with a button.
I just want the number in that input field to populate a span.
<div>
<input type="text" name="balls" id="ballsLeft" value="48"/>
</div>
<span id="ballsleftholder"></span>
Upvotes: 0
Views: 2819
Reputation: 151
It should seems like:
$('#ballsLeft').keyup(function() {
$("#ballsleftholder").text($("#ballsLeft").val());
});
Upvotes: 1
Reputation:
Bind change
event to that input field and in that event do something like this
$('#ballsLeftHolder').html($(this).val());
You can also use keyup
, keydown
events. Just find what will exactly fit for your need.
Checkout this link.
Upvotes: 0
Reputation: 63522
Call the val() on your <input>
element and use one of the following:
Set the HTML contents of each element in the set of matched elements.
$("#ballsleftholder").html($("#ballsLeft").val());
Set the content of each element in the set of matched elements to the specified text.
$("#ballsleftholder").text($("#ballsLeft").val());
Upvotes: 2