私はjQueryが初めてです。シンプルなページを作成しようとしています。Google がホストする jQuery を使用します。stackoverflow の多くの例に基づいて、この小さなコードを書きました。change イベントが発生することはありません。「読み込めません」という警告も表示されません。firebug を調べて Google のスクリプト タグを展開すると、「未定義」と表示されます。Webサーバーを使用せずに、ローカルでテストしています。誰でも私の間違いを指摘できますか?以下のようにコードします。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="./styles/qForm.css" rel="stylesheet" type="text/css"/>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script>
if (!window.jQuery) {
alert("can not load');
}
$('#choice').change(function () {
alert('here!');
if($(this).val() == '0') $(this).addClass('empty');
else $(this).removeClass('empty')
});
$('#choice').change();
</script>
</head>
<body>
<div id="surround">
<div id="top">
<h3 id="title"> Enter Information </h3>
</div>
<div id="bottom">
<select id="choice">
<option style="color: gray;" value="0" selected="selected">Select...</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
</div>
</div>
</body>