多个页面共用一个js文件,但是有些页面没有某个元素,导致报错
if(document.getElementById("id")){
alert('对象存在');
... ...
}
else{
alert('对象不存在');
... ...
}
参考传送门:https://segmentfault.com/q/1010000011586519
if(document.getElementById("id")){
alert('对象存在');
... ...
}
else{
alert('对象不存在');
... ...
}
参考传送门:https://segmentfault.com/q/1010000011586519