Javascript 如何从js中的事件目标获取值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38348258/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 21:22:26  来源:igfitidea点击:

how to get the value from an event target in js

javascriptjqueryjquery-ui-autocomplete

提问by user1765862

inside js function I'm receiving event as parameter, how do you get the value of the event target?

在js函数内部我接收事件作为参数,你如何获得事件目标的值?

function myFn(event){
    ...
    close: function(event){
        var myVal = ... 
        /// should grab from 
        /// event-> arguments -> [0]->target -> property value painted in yellow (abc)        
    }
}

enter image description here

在此处输入图片说明

回答by Micha? Per?akowski

Try:

尝试:

var myVal = event.target.value;