获取组合框选定的值 [英] Get combo box selected value

查看:97
本文介绍了获取组合框选定的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,当单击该按钮时,应该可以向我获取组合框所选项目的值.例如,如果我具有以下组合键和按钮:

I have a button that, when clicked, should get me the value of a combo box's selected item. For example, if I have the following combo and button:

<select id="client-sort-type">
    <option></option>
    <option>Name</option>
    <option>Recent</option>
</select>

<button id="client-sort-submit" type="button">Sort</button>

我想要类似...

<script type="text/javascript">
    $("#client-sort-submit").click(function () {
        var val = $("#client-sort-type").attr("value");
        window.location.href = "Project/Index/" + val;
    });
</script>

仅这是行不通的,它始终不返回任何内容.帮助吗?

Only this isn't working, it always returns nothing. Help?

推荐答案

使用

$("#client-sort-type").val()

这篇关于获取组合框选定的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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