2012-12-13 47 views
0

我試圖從輸入中捕獲按鍵,然後聚焦一個元素。Firefox 17焦點選擇框不工作

<input id="asdfasfd1" /> 
<input id="asdfasfd2" /> 

<select id="currency"><option>bla</option></select> 

​$(function() { 

    var currencyElement = $('#currency'); 

    $('#asdfasfd1').bind('keypress', function(event) { 

     event.preventDefault(); 

     currencyElement.focus(); 
    });  
}); 

http://jsfiddle.net/KkXwT/6/在IE 8,9,10和Chrome 23,但不能在Firefox 17,做了一些知道爲什麼它不工作?

+0

看看這個http://stackoverflow.com/questions/2562723/javascript-focus-and-select-not-working-in-ff或這個http://www.weberforums.com/topic11544.html – Behnil

+0

你提供的jsfiddle對我來說完美無缺。當我在第一個文本框中按下任何鍵時,組合將獲得焦點。我有一個Mac上的Firefox 17.0.1。 – 2012-12-13 08:55:19

+0

behnil這是一個選擇框不是輸入框,它不工作在Firefox 17上運行的Windows 8 – daanl

回答

2

它的工作...檢查這個.. jsfiddle.net/KkXwT/21

在Firefox中是沒有的亮點,讓你感覺它作爲重點。 我已經爲你做出了一些事情來認識到它的重點。

+0

是的,我應該看看,如果我可以風格,所以有一個視覺感謝的幫助。 – daanl

+0

好的,很高興能有所幫助... :) – Anujith