這裏就是我想有發生:jQuery的下一個()剛剛添加的元素
- 有人進入文本輸入字段
- ,當他們擊中了他們的鍵盤上
ENTER
,它增加了一個使用after()
功能當前輸入域後,輸入字段,則側重該領域的投入,使他們能夠繼續打字,這樣做一遍又一遍
繼承人我的代碼是不工作:
$('.table-todo input[type=text]').live('keypress', function (e) {
if (e.which == 13)
{
$parent = $(this).parent('.field');
$.get('projects-add-task.php?show_delete=yes', function (data) { $parent.after(data); }, 'html');
$(this).next('input[type=text]').focus();
}
});
繼承人的projects-add-task.php
內容:
<div class="field">
<input type="text" name="task[]" />
<a href="#" title="Add Task Below" class="todo-add"><img src="images/icon-todo-add.png" alt="" onmouseover="this.src='images/icon-todo-add-h.png'" onmouseout="this.src='images/icon-todo-add.png'" /></a>
<?php if ($_GET['show_delete'] == 'yes') { ?>
<a href="#" title="Delete This Task" class="todo-delete"><img src="images/icon-todo-delete.png" alt="" onmouseover="this.src='images/icon-todo-delete-h.png'" onmouseout="this.src='images/icon-todo-delete.png'" /></a>
<?php } else { ?>
<img src="images/icon-todo-delete-o.png" alt="" />
<?php } ?>
<div style="clear: both;"></div>
</div>
它只是不注重這是通過$.get
增加了輸入和我無法弄清楚如何解決它。它將下一個輸入字段添加到頁面中,但它沒有將其聚焦。
你可以在http://jsfiddle.net/上重現問題並鏈接到它嗎?如果他們能夠自己運行代碼,人們更容易幫忙。 –
不應該'$(this).next('input [type = text]')。focus();'是'$ parent.next('input [type = text]')。focus();'? – banzomaikaka