jQuery onclick not working in browser Edge

2019-08-24 10:12发布

问题:

View:

<asp:PlaceHolder runat="server" ID="myPlaceHolder">
        <button id="cmdMyButton">ButtonName</button>

jQuery:

$(function () {
        $('body').on('click', "#cmdMyButton", function (e) {
            alert("alertmessage");
        });

        ...

Clicking the button cmdMyButton works in Firefox and Chrome, but does absolutely nothing in Edge. I do not get the alert in Edge.

I have tried everything in this topic Microsoft Edge: onclick event stops working? But nothing worked for me. I am using jQuery 3.3.1

回答1:

Solved by updating jQuery to 3.3.1

Header.asax:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" ></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/3.3.1/jquery-ui.min.js" ></script>