function hide(target) {
document.getElementById(target).style.display = 'none';
var ID = document.getElementById(target).value;
For some reason, the display = 'none' part is working perfect, how ever when i pass 'ID' (var ID) via ajax - it just says Undefined.
出于某种原因,display ='none'部分工作正常,当我通过ajax传递'ID'(var ID)时 - 它只是说Undefined。
Any ideas how to get Var ID to be the same as (target) the ID of the div tag?
任何想法如何让Var ID与(目标)div标签的ID相同?
Thanks.
1 个解决方案
#1
0
I would suggest changing the routine to use a more defensive technique:
我建议改变常规以使用更具防御性的技术:
function hide(target) {
if ( typeof target != "string") {
return;
}
var el = document.getElementById(target);
if ( typeof el == "object" ) {
el.style.display = 'none';
var ID = el.value;
// do something with ID
}
}
#1
0
I would suggest changing the routine to use a more defensive technique:
我建议改变常规以使用更具防御性的技术:
function hide(target) {
if ( typeof target != "string") {
return;
}
var el = document.getElementById(target);
if ( typeof el == "object" ) {
el.style.display = 'none';
var ID = el.value;
// do something with ID
}
}