I have one form generated from rails. I tried to change to the input order_bill
using Jquery in the firefox firebug console, but it does not work. I am new to jQuery
.
<form class="edit_order" id="edit_order_1" action="/orders/1" accept-charset="UTF-8" method="post">
<input name="utf8" type="hidden" value="✓" /><input type="hidden" name="_method" value="patch" />
<input type="hidden" name="authenticity_token" value="1IBaRCZ4S1hYp1" />
..
<div id="bill", class="field">
<label for="order_应付款项">应付款项</label><br>
<input type="text" value="4200" name="order[bill]" id="order_bill" />
</div>
<div class="actions"> .. </div>
<div class="actions">
</div>
</form>
In the firebug JS console,
$('#order_bill').html("asdasdddddddddddddddd");
$('#order_bill').html("asdasdddddddddddddddd");
$('#order_bill').html("asdasdddddxx");
$('#bill').html("asdasdddddxx");
But none change on the Html page. Am I wrong?
Try this:
$('#order_bill').val("asdasdddddddddddddddd");
instead of html();
because the value you want to change is present in value attribute of tag.
You may need to make sure you import a jquery library in your html page http://code.jquery.com/jquery-2.2.4.min.js
if you want to get value just Type $('#order_bill').value
and set the value $('#order_bill').value = "enter Value"
But if You Want to add a text in div using jquery
$('#order_bill').html("Value");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.