2
我知道這個問題之前已經被問過了,因爲我在過去的幾個小時里正在尋找一個解決方案。 這個想法是我有一個顯示文本值的表格單元格。點擊事件後,該值將被轉換爲可編輯的輸入字段。jQuery focus()不能在FireFox中工作,但在Chrome中工作
我的代碼在Chrome上完美運行,但是在FireFox中測試時出現輸入文本,但我根本無法編輯該字段。
這裏是我的代碼:
function openInput(product_row) {
var qty = $('[name="order_product[' + product_row + '][quantity]"]').val();
text = '<input type="text" name="enter_order_product[' + product_row + '][quantity]" value="'+qty+'" style="text-align:right;width:30px;" />';
$("#order_product_" + product_row + "_quantity").html(text + '<input type="hidden" name="order_product[' + product_row + '][quantity]" value="' + qty + '" />');
var input = $('[name="enter_order_product[' + product_row + '][quantity]');
input.focus();
}
openInput函數被調用上的表格單元格單擊事件。
我不得不說,我曾嘗試這種解決方法,沒有運氣
setTimeout(function() {
input.focus();
}, 0);
任何想法,將是有益的。乾杯!因爲你缺少收盤"]
非常感謝@詹姆斯·唐納利。這很奇怪,它在鉻合金中運作得很好。編輯後,你如何說在Firefox中的魅力也是如此。感謝您的快速回復和觀察精神:) –