求帮助,非常感谢!提示TypeError: pren.style is undefined错误
一个选择日期的JS,总是报错
TypeError: pren.style is undefined
[在此错误处中断]
if (pren && pren.style.display != "none") {
希望大侠们能帮我看看,真的真的万分感谢呀!就是下面这段:
_$.validaClick = function(e, param) {
var pren = _$.dom(param[0]);
if (pren.length == 0) {
return;
}
if (pren && pren.style.display != "none") {
var arr = new Array();
for (var i = 0; i < param.length; i++) {
var b = _$(param[i]);
for (var n = 0; n < b.length; n++) {
arr[arr.length] = b[n];
}
}
var all_arr = new Array();
for (var i = 0; i < arr.length; i++) {
_$.findNodes(arr[i], null, all_arr);
}
for (var i = 0; i < arr.length; i++) {
all_arr[all_arr.length] = arr[i];
}
var m = _$.getTarget(_$.getEvent(e));
for (var i = 0; i < all_arr.length; i++) {
if (m == all_arr[i]) {
return;
}
}
pren.style.display = "none";
}
}
------解决方案--------------------
var pren = _$.dom(param[0]);
if (pren.length == 0) {
return;
}
这下面加一句:
pren=pren.length?pren[0]:pren;