Thomas
Thomas

Reputation: 34198

Assign same text to multiple DIV by jquery

Suppose that I have many DIVs with different IDs and I want to insert a small snippet of html into all of those DIVs with different IDs. I tried

$("#lblTopPager", "#lblBottomPager").html('hello my data');

but it doesn't work. Can anyone tell me the correct way to do it?

Upvotes: 0

Views: 78

Answers (1)

adeneo
adeneo

Reputation: 318302

Elements need to be a comma seperated list, right now you are giving context, and basically looking for an element with the ID lblTopPager inside the element with ID lblBottomPager, just as if you where using $('#lblBottomPager').find('#lblTopPager').

To target two or more elements at the same time you could do :

$("#lblTopPager, #lblBottomPager").html('hello my data');

Upvotes: 1

Related Questions