2013-07-24 55 views
0

我使用這個演示:如何禁用組合框的輸入?

http://closure-library.googlecode.com/git/closure/goog/demos/combobox.html

但我並不需要用戶輸入,我已經試過這個來禁用它:

combobox.getInputElement().disabled = "disabled"; 

但它不會工作在IE6/IE7中(沒有嘗試IE8/9),這意味着,在IE中禁用的輸入字段無法捕獲點擊事件。

那麼如何禁用它跨平臺?

+0

它在Chrome或Firefox中有效嗎? –

+0

是的,'disabled =「disabled」'在Chrome和FF中工作 – MrROY

回答

0

可以停止按鍵爲寫:

$(document).keypress(function(e) { 

      var key = e.which; 

      if (key == 8 && e.target.attributes[0].value != "type of Element") { 
       return true; 
      } 
      else{ return false;} 

     }); 

你可以設置你的元素類型組合框。