Click on multiple elements with the same class

I try to click on several elements with the same class, but when I do this, the first element receives only one click, and not the others, to be honest, I try to make the answers to all the questions asked.fm like using the firefox console, so that's what i did

$('.like').trigger('click'); 

but I realized that only the first element (answer) is pressed, so I did something else

 $('.like').each(function(){$(this).trigger('click');}) 

but the problem still exists, os, what am I doing wrong here !!

Edit: HTML

all answers received this item in it

 <a class="like hintable" hint="Like" href="#" onclick="Like.quickLike(128332156539, &quot;mo7am_rs&quot;, &quot;/likes/am77r/question/128332156539/add&quot;); return false;" style="display:block"></a> 

and I want to click this element in all response elements

+5
source share
2 answers

Honestly, I'm trying to make the answers I like to all the ask.fm answers

Your code should work, so maybe they ignore / block two too consecutive clicks to prevent bots and skips.

A workaround to this would be to add sleep to it (you must adjust the sleep mode value because it depends on their secret configured threshold).

The following code will try to click every 10 seconds:

 var sleep = 0; $('.like').each(function(){ var likeElement = $(this); setTimeout(function() { likeElement.trigger('click'); }, sleep); sleep += 10000; }); 

Please also check if this practice complies with the site policy.

+4
source

Try this: write a click handler for an entire similar element, and then run it.

 $(function(){ //register a handler $( ".like" ).on( "click", function() { alert( $( this ).text() ); }); //trigger click $( ".like" ).trigger( "click" ); }); 

JSFiddle Demo

+2
source

All Articles