按钮单击jQuery

Sir*_*hil 7 html javascript ajax jquery

我是jQuery的新手.我想使用按钮单击事件来引发警告框.这是我的代码,但它似乎无法工作.救命!请

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Jquery Basic</title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script>
            $(document).ready(function() {
                $('submit1').click(function() {
                    alert("JQuery Running!");
                )};
            });
        </script>
    </head>
    <body>
        <a>JQuery Test Page</a><br>
        <input id="submit1" type="button" value="Submit"/>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

Ror*_*san 23

你缺少的#,从你的id选择.试试这个:

$(document).ready(function(){
    $('#submit1').click(function(){
        alert("JQuery Running!");
    });
});
Run Code Online (Sandbox Code Playgroud)