关于网友提出的“js 错误element is null or not an object”问题疑问,本网通过在网上对“js 错误element is null or not an object”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题:js 错误element is null or not an object
描述:
js源码是:
//CheckBox全选
function CA(){
var frm = document.forms[0];
alert(frm);
for (var i=0;i<>
{
var e=frm.elements[i];
if ((e.name != 'allbox') && (e.type=='checkbox'))
{
e.checked=frm.allbox.checked;
if (frm.allbox.checked)
{
hL(e);
}//endif
else
{
dL(e);
}//endelse
}//endif
}//endfor
}
//CheckBox选择项
function CCA(CB)
{
var frm=document.Form1;
if (CB.checked)
hL(CB);
else
dL(CB);
var TB=TO=0;
for (var i=0;i<>
{
var e=frm.elements[i];
if ((e.name != 'allbox') && (e.type=='checkbox'))
{
TB++;
if (e.checked)
TO++;
}
}
frm.allbox.checked=(TO==TB)?true:false;
}
function hL(E){
while (E.tagName!="TR")
{E=E.parentElement;}
E.className="H";
}
function dL(E){
while (E.tagName!="TR")
{E=E.parentElement;}
E.className="";
}
我的aspx界面如下:
解决方案1:
function hL(E){
while (E.tagName!="TR")
{E=E.parentElement;}
E.className="H";
}
和function dL(E){
while (E.tagName!="TR")
{E=E.parentElement;}
E.className="";
} 应该while循环条件有点问题,改成 while (E&&E.tagName!="TR")
解决方案2:
你访问的对象有问题,不是空值就不是个对象,查他,或者在浏览器中下载一个debug插件,进行调试
以上介绍了“js 错误element is null or not an object”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/1289693.html