且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在jQuery中单击按钮时获取所选下拉值的值

更新时间:2023-11-30 17:11:10

如果您使用控件中的 select ,则无需担心.只需对您的代码做些改动即可.

If you are using select from control then no worry to code for it. Just do a little change in your code.

$('#update').click(function(){
  alert($('#options').val());
});

或者,如果您使用的是 ul,li ,则可以像这样更改您的jquery代码.

Or if you are using ul, li then change your jquery code like this.

$('#update').click(function(){
  alert($('#options .selected').text())
});