简体   繁体   English

奇怪的JavaScript getElementsByName未定义错误

[英]Odd JavaScript getElementsByName undefined error

Okay, I've seriously got to be missing something or I'm crazy. 好吧,我必须要丢失一些东西,否则我会发疯。 Here's the code I'm having an issue with, it is inside an onchange event: 这是我遇到问题的代码,它在onchange事件中:

console.log( (this.parentNode.parentNode) );
// fine prints the elements

console.log( (this.parentNode.parentNode).getElementsByName('otherposition[]') );
// gives me undefined error

(this.parentNode.parentNode).getElementsByName('otherposition[]')[0].style.opacity = '1';
// same error.

getElementsByNamedocument一种方法,元素没有这种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM