jquery set all elements in a given class the same html

13,204

Solution 1

Simply with val:

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

If they're not form elements, use text:

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

Solution 2

If they are all input fields then you can just do this:

$(".totamAmount").val(amt);
Share:
13,204
Didier Levy
Author by

Didier Levy

Updated on June 11, 2022

Comments

  • Didier Levy
    Didier Levy about 2 years

    I have a page with several total fields. They all share the "totalAmount" class.

    I need to set the same value in all these fields with jquery:

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