它很奇怪。我的结构是
<form name="fm">
<input type="file" name="fl">
<input type="text" name="st">
</form>
现在document.fm.st.hidden = true; 可以像预期的那样隐藏文本框,但document.fm.fl.hidden = true; 不起作用,它不隐藏文件上传元素!为什么以及如何解决?
听起来这可能是脚本在页面完全加载之前运行的一种情况。如果要绝对确保在脚本运行之前已加载页面,则可以执行以下操作:
document.onload = function(){ // if you want it could also be window.onload
document.fm.st.hidden = true;
document.fm.fl.hidden = true;
};
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句