Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含几个总字段的页面。他们都共享“totalAmount”类。
我需要使用 jquery 在所有这些字段中设置相同的值:
var amt = some value; $('.totamAmount').each // - Some instruction to set the value to amt;
只需val:
val
$('.totamAmount').val('{the value you want here}');
如果它们不是表单元素,请使用text:
$('.totamAmount').text('{the value you want here}');
如果它们都是输入字段,那么您可以这样做:
$(".totamAmount").val(amt);