I'm having to use a series of iframes containing PayPal 'Buy Now' buttons.
For aesthetic reasons, I want to use a different PayPal button design. As such I have placed my new design over the iframes 'Buy Now' link using CSS absolute positioning. Using jQuery I want a click on this new image to trigger the PayPal iframe button.
There are multiple PayPal buttons on the page so I just want the nearest iframe to be triggered when an image is clicked.
My jQuery codes event is working (I can see the console log output when clicked), however, it's not triggering the iframes button as planned.
/*PayPal Buy Now Button Activation*/
$('.paypal-paynow img').click(function(event) {
console.log('iFrame doohicky');
$(event.target).closest("iframe").click();
});
<div class="paypal-paynow btn1">
<img src="https://foo.com/new-paypal-image" alt="Pay Now Button">
<iframe scrolling="no" src="https://foo.com/dev/product/iframepage1/"></iframe>
</div>
<div class="paypal-paynow btn2">
<img src="https://foo.com/new-paypal-image.png" alt="Pay Now Button">
<iframe scrolling="no" src="https://foo.com/dev/product/iframepage2/"></iframe>
</div>