jQuery get the selected dropdown value on change

后端 未结 6 1750
无人及你
无人及你 2021-01-17 17:51

I\'m trying to get the value of a dropdown on change (and then change the values in a second dropdown).

EDIT: Thanks for all the replies, i\'ve upda

6条回答
  •  失恋的感觉
    2021-01-17 18:13

    val is a method, not a property.

    use it like val()

    If you are using it many places, i would assign it to a local variable and use it thereafter.

    Also you can use the $.now() function to get the unique time stamp. It is equal to DategetTime();

    $('.dropone').change(function() {    
        var item=$(this);
        alert(item.val())
        $(".droptwo").empty();
        $(".droptwo").load("ajaxdropdown.aspx?drpType=room
                            &roomid=" +item.attr("value") + "&ts=" + $.now());
    });
    

提交回复
热议问题