我有html表單,其中包含名稱爲id的輸入標籤 由於某種原因,jQuery將此字段映射到表單id屬性。 如果選中下面你將簡單的HTML會發現jQuery將輸入name = id元素映射到form.id屬性,爲什麼?
$('#f1')[0].id = [input element]#inputid
$('#f2')[0].id = "f2"
有誰知道爲什麼,或者是一個錯誤,並且沒有任何人知道的jQuery名稱= id元素映射到表?
<html>
<head>
<title>Strange jQuery FORM.id behavior</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type=
"text/javascript"></script>
</head>
<body>
<form id="f1" name="f1">
<input id="inputid" name="id" value="ID">
</form>
<form id="f2" name="f2">
<input name="key" value="KEY">
</form>
</body>
</html>
的jQuery移動將嘗試使用這個form.id字符串,如果你的表單包含名稱= ID輸入失敗...
試過大多數瀏覽器,jQuery的verisons,相同的結果。
編輯:
對不起 - 只檢查jQuery的,不是jQuery的手機竊聽器,這已得到糾正MAR-12。 不在1.4.2不過,當用的getAttribute( 'ID')修補,而不是它的工作原理...
https://github.com/jquery/jquery-mobile/commit/9ff610de479097c85ec7289e67fc656e5581d817
不要給你的輸入名稱'ID'。 – j08691
這不是相對於jQuery –