Select の値がいつ変更されるかを検出しようとしています (たとえば、ユーザーがドロップダウン オプションの 1 つを選択します)。しかし、私は物事を発火させることができないようです。私は多くの解決策を試しましたが、明らかに何かが欠けている日がありましたが、木には森が見えません。
私が現在持っているものは次のとおりです。
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- jQueryMobileCSS - original without styling -->
<link rel="stylesheet" href="nativeDroid_v0.2.2/development/css/jquerymobile.css" />
<!-- jQuery / jQueryMobile Scripts -->
<script src="JQueryMobile/jquery-1.10.2.js"></script>
<script src="JQueryMobile/jquery.mobile-1.3.2.js"></script>
<!-- customised styles -->
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script type="text/javascript">
$(".test").change(function() {
//var newVal = $(this).val();
alert("The new value is: " + $(this).val());
});
</script>
</head>
<body>
<select name="select-choice-enmeasurement" id="select-choice-enmeasurement" class="test">
<option value="C45">C45</option>
<option value="M3">M3</option>
<option value="M5">M5</option>
<option value="M8">M8</option>
</select>
</body>
</html>
上記も試しましたが、選択コントロールの Id ではなくクラスを検出しました。
Ps 上記は JQM プロジェクトから抽出されたものであるため、純粋に JqueryMobile への参照があります。ただし、競合などの可能性を排除するために、このフォームの独自のページとして上記を作成しました。
任意のアイデア/提案をいただければ幸いです。ありがとう。