简体   繁体   中英

Setting a value for an input per jquery

I am a bit puzzled by this behaviour.

I clone a table with jquery, then do a GET request to the server and get a json. From that I set the value for each field in the cloned table.

在此输入图像描述

It all appears just fine on the screen, however I don't see any value in FireBug for that element.

<input id="id_deals-1-deal_template_name" type="text" maxlength="100" name="deals-1-deal_template_name" readonly="True">

The way I set the value is like this, maybe I do this wrong:

$('#id_deals-' + (total-1) + '-deal_template_name').val(template_name);

The value attribute sets the default value .

The value property, which is set by the jQuery val() , method deals with the current value .

You shouldn't see a change in the attribute when viewing in Firebug as you aren't changing the default value.

If you really want to change that then use .attr('value', foo) instead.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM