javascript auto click several buttons with same class at once

dalooroorl

Newbie
Joined
Sep 15, 2013
Messages
15
Reaction score
0
goo.gl/ MNR1ZB

as u see, i want to click the unfollow buttons at once, i did it with a code, but it only clicks on the first one...

can any1 help me?
 
Does this not work? Replace "selector" with the class of the unfollow buttons.

Code:
jQuery(document).ready(function($) {
$("selector").click();
});
 
ty for reply bro, but that was the code i used :D
 
Hmm, you could make an iMacro. It might be an easier solution.
 
Try this:
Code:
$("selector").each(function(){click()});
 
try this one.


<script>
$(document).ready(function(){

$(".ClassSelectorHere").click(function(){

//do something here

});

});
<script>



hope this helps. btw, don't forget the jquery library. :)
 
Last edited:
You have to put a dot in front of the class name in the selector to work, so no $('classname') but $('.classname'), maybe this was the problem? Also, jQuery needs to be included in the web page for this to work.
 
That way will work with jQuery, but the title says Javascript so I'm a little confused.
If you need It in javascript, here is the code:
Code:
function clickAllButtons() {
        var allButtons = document.getElementsByClassName("yourItemsClass");
        for(i=0;i<allButtons.length;i++) {
               // do whatever you wanna do here
            }
        }
    }
    window.onload = clickAllButtons;
try this one.


<script>
$(document).ready(function(){

$(".ClassSelectorHere").click(function(){

//do something here

});

});
<script>



hope this helps. btw, don't forget the jquery library. :)
 
ty all, but nothing works.

the button code:

Code:
<a class="unfollow-button" href="unfollow?url=xxx"></a>

EDIT: I find out how! with this code:

Code:
javascript:e=document.getElementsByClassName('unfollow-button');for(i=0;i<e.length;i++){e[i].click();}void(0);

Thank you all!
 
Last edited:
Back
Top