user28928120
user28928120

Reputation: 43

how to select all classes in jquery?

this jquery code :

$('.menu_item_wrap')[0].style.setProperty('border-top', '1px solid #E7E7E7', 'important');

select the first class "menu_item_wrap" only . also i need it because the important Property .

if i delete the [0], the code will not work. and if i use this code :

$('.menu_item_wrap').css({"border-top": "1px !important"});

the !important doesn't work.

how to select all classes within this code :

$('.menu_item_wrap')[0].style.setProperty('border-top', '1px solid #E7E7E7', 'important');

Upvotes: 0

Views: 44

Answers (1)

trueicecold
trueicecold

Reputation: 879

You'd have to loop it:

$('.menu_item_wrap').each((index, item) => {
    item.style.setProperty('border-top', '1px solid #E7E7E7', 'important');
});

Upvotes: 2

Related Questions