Reputation: 439
I am trying to hide a dollar sign in an input field. I am populating the input field with some values from buttons, so when you click on the button it will populate the field, but it is still showing the dollar sign still for some reason. Some help will be much appreciated.
Thanks,
Here is my fiddle - http://jsfiddle.net/7Shzg/1/ and the code bellow
$('#amount').html($('#amount').html().replace("$",""));
$( "button" ).click(function() {
var text = $( this ).text();
$( "#amount" ).val( text );
});
Upvotes: 0
Views: 1702
Reputation: 28513
Try this : replace $
with empty space while reading text value. Also you got two element with same id in jsfiddle. put id = "amount" for input box.
HTML :
<label>Sum:</label>
<input type="text" id="amount" name="amount">
<ul id="money">
<li>$500</li>
<li>$1000</li>
</ul>
jQuery :
$( "#money li" ).click(function() {
var text = $( this ).text().replace('$','');
$( "#amount" ).val( text );
});
Upvotes: 1