我在IE7測試一行代碼,但它給我下面的錯誤:對象不支持此屬性或方法document.querySelector
Object doesn't support this property or method and it refers to
這裏的問題線問題:
var checked = document.querySelector('[name="answer1"]:checked');
這是整個代碼
問題1:你喜歡訓練嗎?
<input name="q4" value="Yes" type="radio"> Yes
<input name="q4" value="No" type="radio"> No
<br>
<button id="getval">cick here</button>
<script type="text/javascript">
document.getElementById('getval').onclick = function() {
var checked = document.querySelector('[name="q4"]:checked');
alert(checked ? checked.value : 'Not selected');
}
</script>
有沒有辦法解決這個問題?
其中IE的版本?所有IE? – Rishabh 2013-03-24 17:13:28
是的,特別是7 – 2013-03-24 17:14:01
我在IE10有類似的問題...任何想法? – 2013-11-08 21:25:34