Javascript HTML onchange (this.value)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32477105/
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 08:06:35  来源:igfitidea点击:

HTML onchange (this.value)

javascripthtmlonchange

提问by e.klara.k

We found this in our code (we haven't written it by our selfs, and we are new to programmng), can anyone explain what this.value means and how you change it?

我们在我们的代码中发现了这个(我们不是自己写的,我们是编程新手),谁能解释一下 this.value 的含义以及如何更改它?

<select id="sel_target" onchange="paint(this.value);sendid(value); highlight(value);move_to(value)">

Thank you!

谢谢!

回答by SVK

this.value represents the selected value.

this.value 表示选定的值。

Example:

例子:

function getComboA(sel) {
    var value = sel.value;  
}

<select id="comboA" onchange="getComboA(this)">
<option value="">Select combo</option>
<option value="Value1">Text1</option>
<option value="Value2">Text2</option>
<option value="Value3">Text3</option>
</select>

The above example gets you the selected value OnChangeevent.

上面的示例为您提供了选定的值OnChange事件。