jQuery only loads after refresh
Hi,
I am using WordPress on my site and I have created a custom jquery in order to add the qty input fields again:
- jQuery(document).ready(function($){
- $('.quantity').on('click', '.plus', function(e) {
- $input = $(this).prev('input.qty');
- var val = parseInt($input.val());
- $input.val( val+1 ).change();
- });
- $('.quantity').on('click', '.minus',
- function(e) {
- $input = $(this).next('input.qty');
- var val = parseInt($input.val());
- if (val > 0) {
- $input.val( val-1 ).change();
- }
- });
I embedded it into my header like this:
- function state_dropdown_scripts() {
-
- wp_enqueue_script( 'theme_functions_scripts', get_stylesheet_directory_uri() . '/js/scripts-min.js', array(), null, false );
- }
Whenever i add a product into my cart and try to click on one of the qty input fields, it does not add or remove any quantities. It works right after I refresh the page:
Do you have an idea on how to fix that?
Thanks!!