Nookster Nookster - 1 year ago 72
jQuery Question

Loop through links on site and click links javascript/jquery

I am trying to loop through all the links on a site and autoclick some links in order to vote for here is what I have so far:

function x(){
for(var e in document.getElementsByTagName("a")){

This currently does not work I think it maybe to do with something simple like the braces/; key, I'm an absolute beginner to javascript so please bear with me.
I assume you get the drift of what I want to do, I have completed this task in another language but still did not get the vote to register, I believe this maybe something to do with the site using jquery? My question is, How can I get this simple script working for a start, and 2) Is there a different click method for Jquery I can use instead of what I have up there 3) How Can I check for 6 specific URLs and click only these. I also need to execute this from the browser using javascript:xxx_code_here

Any ideas?

Thank you

Answer Source

use jquery like

$("a").each(function ()
   $(this).trigger('click');//for clicking element
   var href = $(this).attr("href");

You can use trigger: