这肯定是一个JS初学者问题。关于DOM的变量
我的问题是我想使用变量type
的值来访问相关的复选框;但是它将该变量视为一个字符串。我尝试过两种方法。
function toggleGroup(type) {
if (document.getElementById(type).checked == true){
alert("foo");
}
}
或
function toggleGroup(type) {
if (document.nav.type.checked == true){
alert("foo");
}
}
确实比较。举例来说,'foo'是最复杂思想的选择。 – jrharshath 2009-06-18 12:00:00