Sleazy Fork is available in English.

Συζητήσεις » Ανάπτυξη

How to click on all anchor of same class on a page

§
Δημοσιεύτηκε: 01/01/2019

How to click on all anchor of same class on a page

i want to click on all the anchor which have the same class as *like-stream-item * i tried few codes but only on click works not all

§
Δημοσιεύτηκε: 01/01/2019

[].forEach.call(document.querySelectorAll('.like-stream-item'),item=>item.click());

§
Δημοσιεύτηκε: 02/01/2019

@indefined said: [].forEach.call(document.querySelectorAll('.like-stream-item'),item=>item.click());

it works but as the click happen to all the class name changes from like-stream-item ** to **like-stream-item is-liked but it click on it too

§
Δημοσιεύτηκε: 02/01/2019

before click its

<a href="#" class="like-stream-item " data-ember-action="" data-ember-action-319="319">

after click <a href="#" class="like-stream-item is-liked" data-ember-action="" data-ember-action-319="319">

but the click code works again after class name is changed

§
Δημοσιεύτηκε: 02/01/2019

@"Ankit Singh" 说道: before click its

<a href="#" class="like-stream-item " data-ember-action="" data-ember-action-319="319">

after click <a href="#" class="like-stream-item is-liked" data-ember-action="" data-ember-action-319="319">

but the click code works again after class name is changed

[].forEach.call(document.querySelectorAll('.like-stream-item:not(.is-liked)'),item=>item.click());

Δημοσίευση απάντησης

Συνδεθείτε για να δημοσιεύσετε μια απάντηση.