• Resolved chewventure

    (@chewventure)


    I have installed the plugin and have a jQuery script that works fine if it’s inserted inline in the HTML.

    I have a button with a class like so:

    <button type="button" class="bookingbutton">Click here</button>

    And my jQuery script appears like:

    jQuery(document).ready(function( $ ){
    
      $('.bookingbutton').click(function() {
        alert('a message');
    });

    But for some reason that I can’t fathom it doesn’t work. When I click the button it doesn’t even appear to attempt to run the jQuery.

    What could be interfering here?

    I have the exact same thing running fine on 2 other sites – I just can’t figure this one out.

    To re-iterate, the jQuery works ok if inserted inline in the HTML, but I just can’t understand why the scripts inserted into the plugin UI don’t work in the same way?

    What am I missing?

    • This topic was modified 4 years, 4 months ago by chewventure.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author SilkyPress

    (@diana_burduja)

    There is a closing bracket missing. Try the following jQuery script:

    jQuery(document).ready(function( $ ){
    
      $('.bookingbutton').click(function() {
        alert('a message');
      });
    });
    

    The first closing bracket (line 5) ends the “click” handler. The second closing bracket (line 6) ends the “ready” handler.

    Thread Starter chewventure

    (@chewventure)

    Sorry, that was a typo when stripping out personal data from my function.

    Hmm, I don’t know why it would work on 2 sites, but not on my other one. Really a mystery – in the end I added the jQuery manually and it works. So strange.

    Probably never get to the bottom of it!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘What would be stopping the jQuery scripts from being called?’ is closed to new replies.