我需要使用Dojo做一个项目,我完全混淆了如何处理一组无线电。考虑如下的示例,使用
很容易获得所选值$('input[name=map]').on('change', function() {
console.info($(this).val());
});
但是,请你知道如何做到这一点就是道场
require([ "dojo/dom",
"dojo/on",
"dojo/domReady!"], function(dom, on) {
//------?
});
// jQuery way
$('input[name=map]').on('change', function() {
console.info($(this).val());
});
// Dojo Way ???

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.11.2/dojo/dojo.js"></script>
<input type="radio" name="map" value="dark"> Dark<br>
<input type="radio" name="map" value="streets"> Street<br>
<input type="radio" name="map" value="terrain"> Terrain
&#13;
由于
答案 0 :(得分:1)
您需要使用 // Dojo Way:
require(["dojo/on", "dojo/query", "dojo/domReady!"],
function(on, query) {
query("[name='map']").map(function(radio){
on(radio, "change", function(evt){
console.log(this.value);
})
})
});
。这应该做到这一点。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.11.2/dojo/dojo.js"></script>
<input type="radio" name="map" value="dark"> Dark<br>
<input type="radio" name="map" value="streets"> Street<br>
<input type="radio" name="map" value="terrain"> Terrain
&#13;
<?php
$servername = "";
$username = "";
$password = "";
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
&#13;