简体   繁体   中英

.click event is not working in safari

I have a .click event in JavaScript, it seems to be working fine in all major browsers except for safari. Code is creating a dialog box that display's an image when the submit button is clicked.

$(document).ready(new function () {
var SpinnerImage = ('<div id="dialog-message"><img src="loading.gif" /></div > ');
$("#ctl00_mainContent_AppPaymentControl1_applicationPaymentControl_payNow").click(function () {
    //show loading gif
    $('body').append(SpinnerImage);
    $("#dialog-message").dialog(
        {
            title: 'Loading... Please Wait'
        });
    });
});

Any help would be appreciated.

See if this works?

1  $(document).ready(function () {
2     var SpinnerImage = $("<div id='dialog-message'><img src='loading.gif' /></div>");
3     $("#ctl00_mainContent_AppPaymentControl1_applicationPaymentControl_payNow").click(function () {
4        //show loading gif
5        $('body').append(SpinnerImage);
6        $("#dialog-message").dialog(
7           {
8              title: 'Loading... Please Wait'
9           }
10       );
11    });
12 });

Corrections:

  • Remove new on line 1
  • Add $ on line 2
  • Fix faulty single- and double- quotes on line 2

You mentioned in a comment that #ctl00_mainContent_AppPaymentControl1_applicationPaymentControl_payNow is an <input> element. Try using the $(element).focus(callback); method instead of $(element).click(callback);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM