Jquery不工作在Windows8 HTML 5应用程序

Jquery not working in Windows8 HTML 5 App

本文关键字:HTML 应用程序 Windows8 工作 Jquery      更新时间:2023-09-26

我创建了新的Windows 8 HTML 5应用程序。我添加了jquery文件。但是Hello World!没有被打印到TextBox

MainPage.xaml.cs

private void Browser_Loaded(object sender, RoutedEventArgs e)
    {
        // Add your URL here
        Browser.IsScriptEnabled = true;
        Browser.Navigate(new Uri(MainUri, UriKind.Relative));
    }

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="/html/css/phone.css" />
    <title>Windows Phone</title>
    <script type="text/javascript" src="~/Scripts/jquery-2.0.0.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function (){
            $("#test").val("Hello World!");
        });
    </script>
</head>
<body>
    <div>
        <p>Climate</p>
    </div>
    <div id="page-title">
        <p>My Climate</p>
        <input type="text" id="test" />
    </div>
</body>
</html>

我的猜测是脚本URI中的"~/"没有被正确解释,或者URI在其他方面不正确。我知道jQuery在W8应用程序中工作得很好。

我会把它移动到你的应用程序的路由目录中,或者相对地引用该文件。