2009-10-17 195 views

回答

2

嘗試的東西,如:

$(document).ready(function() { 
    $("#listbox1").change(function() { 
     if ($(this).val() != "") 
      $("#listbox2 option:selected").attr("selected", ""); 
    }); 
    $("#listbox2").change(function() { 
     if ($(this).val() != "") 
      $("#listbox1 option:selected").attr("selected", ""); 
    }); 
}); 
+1

工作,但它不適用於IE6。這是正常的嗎? – Robert

+0

也許你可以試試removeAttr(「selected」) –

+0

no :-(,它不工作 – Robert

4
$(function() { 
    var list1 = $("#listbox1"); 
    var list2 = $("#listbox2"); 

    list1.change(function() { 
     $("option", list2).attr('selected', false); 
    }); 

    list2.change(function() { 
     $("option", list1).attr('selected', false); 
    }); 
}); 
0

我認爲阿龍的回答將工作跨瀏覽器的,但是在這樣的單選按鈕的情況下,應使用,而不是複選框...

無線電盒是專門爲這種情況設計的...

相關問題