2009-12-05 68 views
0

我有2个列表。锁定区域列表?

国家和地区

我想锁定区域列表。当我选择国家时,我将使用jquery获取该国的区域列表。但同时我希望区域列表被锁定,并在该国家/地区列表被检索时首先进行互动。

我该如何做到这一点与jQuery的?

回答

2

你的问题有点我不清楚,但它听起来像你想禁用掇下拉列表。如果是这种情况,你可以试试这个。

//Disable code: 
$('select#region').attr('disabled', 'disabled'); 

//Enable code: 
$('select#region').removeAttr('disabled'); 
0

使用jQuery的绑定和取消绑定的功能,如:

var country = function() { 
    // unbinds itself 
    $('a.country').unbind('click', country); 
    // ... the rest of your code, including ajax request 
    // wich will "rebind" the function again when finished 

}; 

// bind initially the function to the handler 
$('a.country').bind('click', country); 

}); 

希望你能理解:)

+0

虽然我读了文档,但实际上并不明白。 如果我重新配置:我如何使选择列表不可点击? – 2009-12-05 03:48:28

+0

啊,没有提到你想要一个选择列表..在这种情况下,@Greg W的答案更适合你。 – yoda 2009-12-05 05:03:40