0
http://pastebin.com/r30Wfvi3JavaScript中,突然的jQuery沒有檢測到我的複選框被選中
突然所有這一切剛剛停止工作。
var showMyLocation = document.createElement('input');
showMyLocation.type = "checkbox";
showMyLocation.className = "checkboxForRange";
showMyLocation.id = "showMyLocation";
$$.children("#showMyLocation").html('<p style="float:left">Vis min posisjon :</p>').append(showMyLocation);
$('#' + showMyLocation.id).change(function() { //location
console.log("clicked");
if ($(this).is(":checked")) {
console.log("y");
GarageHandler.showPosition();
} else {
console.log("n");
GarageHandler.hidePosition();
}
});
這裏的輸出給定代碼:
"clicked"
"n",
"clicked"
"n",
"clicked"
"n",
"clicked"
"n",
etc.
應該是這樣:
"clicked"
"y",
"clicked"
"n",
"clicked"
"y",
"clicked"
"n",
etc.
有誰知道什麼是錯?
請張貼在問題的代碼,並進行現場演示重現該問題。 – elclanrs
看起來像你有一個容器和輸入字段相同的編號 –
像http://jsfiddle.net/arunpjohny/2EMDR/1/ –