【问题标题】:Chained dropdownbox not working in latest jquery version链接的下拉框在最新的 jquery 版本中不起作用
【发布时间】:2011-05-30 19:30:07
【问题描述】:

我有一个出色的功能,可以在选择国家/地区后填充度假村下拉框。现在,使用 jquery 1.6,度假村下拉框不再填充。有谁知道是什么原因造成的。

function populate_country() {
    $.getJSON('/v3/ajax/fetch_resort.php', {country:$('#country').val()}, function(data) {
        var select = $('#resorts');
        var options = select.attr('options');
        $('option', select).remove();
        $.each(data, function(index, array) {
        options[options.length] = new Option(array['resort']);
        });
    });
}


$(document).ready(function() {  

$("#country").click(function(){
// populate_country();
    $('#country').change(function() {
        $loading.show(); 
        populate_country();
        $("#resorts").show("fast"); 
    });
});

});

【问题讨论】:

    标签: jquery chained jquery-selectbox


    【解决方案1】:

    在我看来,这似乎与attr 发生了变化有关。尝试改用prop

    在此处查看更多信息:.prop() vs .attr()

    【讨论】:

      猜你喜欢
      • 2014-05-05
      • 1970-01-01
      • 2022-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-08
      • 2015-06-10
      相关资源
      最近更新 更多