简体   繁体   English

对于javascript中的“oneevent change”,我试图访问函数的参数,但收到“未定义”的错误

[英]For "onevent change" in javascript I am trying to access the parameter of the function, but getting an error as "undefined"

I have a code as below:我有一个代码如下:

<input type="text" id="GAMES" name="OwnGames" width="100%" onChange="ValidateText(document.getElementById('GAMES'))";

Javascript: Javascript:

function ValidateText(e,Games) {
    console.log(Games.id);
    var text_value=e.target.value;
    console.log(text_value);
 }

Console logs is correctly giving event e, but giving an error as Games is undefined.控制台日志正确给出事件 e,但由于游戏未定义而给出错误

After removing argument Games, I am getting an error as e is undefined.删除参数游戏后,我收到一个错误,因为e 未定义。

We have an easy way to access all the element property and values.我们有一种简单的方法来访问所有元素属性和值。 Please refer the snippet.请参考片段。

 function ValidateText(event) { var text_value= event.target.value; var id = event.target.id; console.log(`value : ${text_value}, id : ${id}`) }
 <input type="text" id="GAMES" name="OwnGames" width="100%" onChange="ValidateText(event)" >

暂无
暂无

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

相关问题 我在尝试访问 function 参数时遇到错误“数据”未定义,如以下代码的注释中所述 - I am facing an error 'data' is undefined when trying to access the function parameter as mentioned in the comment in below code 我的javascript函数出现函数未定义错误 - I am getting a function undefined error with my javascript function 我得到:尝试访问javascript clas中的对象时,无法调用未定义的方法“ someMethodName” - I am getting: Cannot call method 'someMethodName' of undefined when trying to access an object in a javascript clas 为什么我收到此错误“未定义不是函数” - why I am getting this error “undefined is not a function ” 类型错误:无法读取未定义的属性“then”。 当我尝试运行 updatefirst 函数时出现此错误 - TypeError: Cannot read property 'then' of undefined. Getting this error when I am trying to run updatefirst function 当我尝试在 JavaScript 中将变量从一个函数传递到另一个函数时,我收到 Reference Error: variable is not defined 错误(邮递员) - I am getting Reference Error: variable is not defined error when I am trying to pass variable from one function to another in JavaScript ( postman) 在js中的原型继承期间,当我尝试访问继承对象的方法时,我变得未定义 - during prototypal inheritance in js, i am getting undefined when i am trying to access the method of inherited object 我正在尝试仅在 ol 标签中更改 li 标签的样式,但收到错误消息 - items[i].document is undefined - I am trying to change the style of li tags in just ol tags but getting error message- items[i].document is undefined 试图用JavaScript计时,出现错误,Uncaught TypeError:undefined不是函数 - Trying to make a clock in JavaScript, getting an error, Uncaught TypeError: undefined is not a function 为什么在尝试分页时出现语法错误(JavaScript)? - Why am I getting syntax error (JavaScript) trying to do a pagination?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM