I am trying to programmatically click the "zoom in" icon three times on a page. The <a>
is structured:
<a class="get-plus" title="zoom in" href="javascript:void(0)" style="display: inherit;"> </a>
I have the following code, called on document ready:
function zoomIn() {
// Zoom in
for (var i = 0; i < 3; i++) {
$('a.get-plus').trigger('click');
alert(i);
}
}
I get the alerts that the loop works, but the zoom functionality isn't working, not sure how to fix or a better way to go about this?
Your way to trigger the click event doesn't work.
Instead use HTMLElement.click():
Therefore, change it from:
to:
The example:
More reading: