2013-10-04 23 views
0

我使用以下更改CONTENTEDITABLE表格單元格的值,然後專注於它無法在Internet Explorer中注重CONTENTEDITABLE表格單元格

$("#click").click(function(){ 
     $("#location").text("me"); 
     $("#location").focus(); 
     return false; 
}); 

上述工程在Chrome和Firefox,但不在IE中。在Internet Explorer中,處理文本方法,但焦點方法不起作用。小提琴here。我嘗試使用setTimeout的combination與jQuery方法並使用vanilla JavaScript來獲取DOM元素。不幸的是,這些方法都沒有強制IE將重點放在元素上。

回答

1

我將HTML屬性從TD轉移到內部DIV。

<td id = 'location' contenteditable = 'true' width = '250px'> 
    <div contenteditable = 'true'> 

成爲

<td> 
    <div contenteditable = 'true' width = '250px' id = 'location'> 

解決的問題。工作fiddle

+0

如果單元大小不固定,請添加'display:inline-block;寬度:100%;高度:100%;'div格式。 – insp

相關問題