You can navigate all the anchors and click on them, yes:
var myLinks = document.getElementsByTagName("a");
for (var i = 0; i < myLinks.length; i++) {
myLinks[i].click();
}
Note that this will click every link on the page. You can focus more on a specific set of links by going through the parent container that is outside of them:
var myLinks = document.getElementById("container").getElementsByTagName("a");
, id "container".
Update2:
, , id . , :
jQuery, id='reviews-show...' :
$("a[id^='reviews-show']").click();
^= , , "review-show", a, .
javascript, , :
var myLinks = document.getElementsByTagName("a");
for (var i = 0; i < myLinks.length; i++) {
currentlink = myLinks[i];
if (currentlink.id.substring(0,12) === "reviews-show") {
currentlink.click();
}
}
Update:
- jQuery , . jQuery ( ), :
$("a").click(); //clicks all links on page
$("#container a").click();//clicks all links within element having id 'container'
, , :
HTMLElement.prototype.click = function() {
if (document.createEvent) {
var evt = this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
} else if (this.fireEvent) {
this.fireEvent("onclick");
}
}
: http://www.barattalo.it/2009/11/18/click-links-with-javascript/