user938363
user938363

Reputation: 10350

How to remove matched attribute in each and every matched element in jquery?

$('#quote_test_item_ids').removeAttr('disabled');

.removeAttr(AttrName) above only removes 'disabled' attribute in first matched element #quote_test_item_ids. There are more than one #quote_test_item_ids in the html page. How to remove each and every attribute 'disabled' on the html page?

Upvotes: 0

Views: 66

Answers (2)

Gigi
Gigi

Reputation: 4962

If you make "quote_test_item_ids" a class attribute of the divs, then you can do the following:

$("div.quote_test_item_ids").removeAttr('disabled');

Upvotes: 1

gen_Eric
gen_Eric

Reputation: 227200

The problem is that you have multiple elements with the same ID. That's a no-no. IDs are supposed to be unique. Change them to classes instead, then do:

$('.quote_test_item_ids').removeAttr('disabled');

Since IDs are unique, $('#quote_test_item_ids') returns the 1st (since there shouldn't be others). You can cheat a bit by using the attribuite selector:

$('[id="quote_test_item_ids"]').removeAttr('disabled');

Upvotes: 2

Related Questions