-3

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="&#x2713;" /><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?

Super User
  • 9,448
  • 3
  • 31
  • 47
shijie xu
  • 1,975
  • 21
  • 52

2 Answers2

1

Try this:

$('#order_bill').val("asdasdddddddddddddddd");

instead of html();

because the value you want to change is present in value attribute of tag.

Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59
1

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");