开发者

Getting text of html select in javascript?

select.onchange = function() {
   this.value; 

}

It's easy to retrieve the value b开发者_高级运维ut now I need the text of the selected element. How to do it?


(Sorry... put .value before my edit instead of .text by accident 8-)...)

this.options[this.selectedIndex].text


//assuming "this" is the select element
if (this.selectedIndex >= 0) {
  this.options[this.selectedIndex].text = "some text";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜