Discussions » Development

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

§
Posted: 2019-01-01

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

§
Posted: 2019-01-01

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

§
Posted: 2019-01-02

@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

§
Posted: 2019-01-02

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

§
Posted: 2019-01-02

@"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());

Post reply

Sign in to post a reply.