jquery set all elements in a given class the same html

class, each, jquery, set

Solution

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}');

Problem

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; ```

Original source