jQuery按钮未被单击

jQuery按钮未被单击,jquery,jquery-mobile,Jquery,Jquery Mobile,这段代码有什么问题 <!DOCTYPE html> <html> <head> <title>WebService Example</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href

这段代码有什么问题

<!DOCTYPE html> 
<html> 
<head> 
    <title>WebService Example</title>         
    <meta name="viewport" content="width=device-width, initial-scale=1">             
        <link rel="stylesheet" href="jquery.mobile-1.0.1.min.css" />
        <script src="jquery.js"></script>
        <script src="jquery.mobile-1.0.1.min.js"></script>            
        <script type="text/javascript">                
            $("#Btn").click(function (event) {
                    alert("Button Clicked");                             
                });                                                         
        </script>            
</head> 
<body>         
    <div data-role="page">
        <div data-role="header" data-nobackbtn="false">
            <div><a href="index.html">Back</a></div>
        </div>                        
        <div data-role="content">
            This is the content
        </div>                        
        <div data-role="footer">                    
            <a href="#" data-role="button"
                    data-icon="info" id="Btn">Button</a>
        </div>            
    </div>        
</body>

Web服务示例
$(“#Btn”)。单击(函数(事件){
警报(“点击按钮”);
});                                                         
这就是内容

代码在DOM准备就绪之前运行。将其放入DOM事件处理程序中:

$(document).ready(function() {
    //Code that interacts with the DOM (such as binding event listeners...)
    $("#Btn").click(function (event) {
        alert("Button Clicked");                             
    }); 
});

代码在DOM准备就绪之前运行。将其放入DOM事件处理程序中:

$(document).ready(function() {
    //Code that interacts with the DOM (such as binding event listeners...)
    $("#Btn").click(function (event) {
        alert("Button Clicked");                             
    }); 
});

将脚本放在主体之后,以便浏览器在找到按钮后附加事件


或者将它放在document.ready中。

将脚本放在正文之后,这样一旦找到按钮,浏览器就会附加事件

或者把它放在文件里。准备好了