jquery将给定类中的所有元素设置为相同的html

我有一个包含几个总字段的页面.它们都共享“totalAmount”类.

我需要使用jquery在所有这些字段中设置相同的值:

var amt = some value; 
$('.totamAmount').each // - Some instruction to set the value to amt;

解决方法

只需使用 val

$('.totamAmount').val('{the value you want here}');

如果它们不是表单元素,请使用text

$('.totamAmount').text('{the value you want here}');

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...