I need to put an alert on WooCommerce Place Order button.
When I put the code below with id ‘place_order’ it is not working. But when I change this id with any other elements ID and click there it works!
I need this alert to work when I click on the following button:
jQuery(document).ready(function($) {
$(function() {
$('#place_order').click(function() {
alert("This is a test message... please ignore this.");
});
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="Place order" data-value="Place order">Pay securely with WorldPay</button>
Can you please tell me what am I missing? Is it because the button calls ajax? if yes how can I make this work?
Thanks
3
Answers
This how you do it to a link button or normal button:
But you are using a submit button, so the form is submitted and you can’t see the message.
The is a way to stop the form submission if you need it:
Hope it helps you
your code must be somehow like this, you can check what you are missing .
Hope I could help!
This how you do it to a link button or normal button:
But you are using a submit button, so the form is submitted and you can’t see the message. The is a way to stop the form submission if you need it: