我有以下结构化妆未来CONTENTEDITABLE元素编辑
<div>
<ul id='t1'>
<li id='l1' contenteditable='true' class='editable'> Lorem ipsum </li>
<li id='l2' contenteditable='true' class='editable'> Lorem ipsum </li>
<li id='l3' contenteditable='true' class='editable'> Lorem ipsum </li>
</ul>
</div>
当用户编辑说李L3,当他打进入我希望与CONTENTEDITABLE =真实,SETFOCUS上添加新的利我想在这里新的李,使用户可以开始在那里输入。 我能够在输入时添加新条目,但无法将焦点放在它上面。
更新
if(e.keyCode == 13){//enter Key or tab key 9
e.preventDefault();
var taskId = this.id;
jQuery.ajax({
url : 'update_current',
type : 'put',
success : function(resp){ //resp is the new li tag
var li = this_is_current_elemtn;
jQuery(li).append(resp);
//$('#t1 .editable').each(function(){
// $(this).attr('editable', 'false');
//});
console.log(jQuery(li).next());
jQuery(li).next().focus();
// $('#t1 .editable').each(function(){
// $(this).attr('contentEditable', 'true');
// });
}
});
任何帮助表示赞赏
你尝试过什么吗? – Johan
如果你已经创建了元素,那么你可以使用$(“#younewelement”)。 –
用焦点和选择尝试,但仍然当前contenteditable保持焦点,不转移焦点到新添加的元素 – Ross