如何在html选择的onChange上传递参数 [英] How to pass parameters on onChange of html select

查看:34
本文介绍了如何在html选择的onChange上传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 JavaScript 和 jQuery 的新手.我想显示一个组合框-A,它是一个 HTML <select>,其选定的 id 和内容位于 onChange() 的另一个位置.

I am a novice at JavaScript and jQuery. I want to show one combobox-A, which is an HTML <select> with its selected id and contents at the other place on onChange().

如何传递带有选择 id 的完整组合框,以及如何在 onChange 事件触发时传递其他参数?

How can I pass the complete combobox with its select id, and how can I pass other parameters on fire of the onChange event?

推荐答案

function getComboA(selectObject) {
  var value = selectObject.value;  
  console.log(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>

上面的例子让你在OnChange<上选择组合框的值/a> 事件.

The above example gets you the selected value of combo box on OnChange event.

这篇关于如何在html选择的onChange上传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆