Này người xa lạ!

Còn chờ gì nữa mà không mau đăng nhập hoặc đăng ký để cùng tham gia thảo luận với cộng đồng!

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

Bình luận

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

  • @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

  • 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

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

Đăng nhập hoặc Đăng ký để gửi bình luận.