答案 0 :(得分:1)
function gettext(sel) {
alert(sel.options[sel.selectedIndex].getAttribute('displayvalue'));
}
<select onchange="gettext(this)">
<option value="1" displayvalue="text 1">Very very long text 1</option>
<option value="2" displayvalue="text 1" selected>Very very long text 2</option>
<option value="3" displayvalue="text 1">Very very long text 3</option>
</select>
使用Dom监听器
$elem = document.querySelector('select')
$elem.addEventListener('change', gettext)
function gettext() {
console.log(this.options[this.selectedIndex].getAttribute('displayvalue'));
}
<select>
<option value="1" displayvalue="text 1">Very very long text 1</option>
<option value="2" displayvalue="text 2" selected>Very very long text 2</option>
<option value="3" displayvalue="text 3">Very very long text 3</option>
</select>