我正在尝试添加一个以创建文本框数组,每次创建一个文本框都应该重点关注。这是我不工作的代码。任何帮助将非常感激。谢谢。
var emails = new Array();
var count = 0;
//function to add more extra emails
$('#additional_emails').focus(function() {
emails[count] = '<input type="text" size="30" id="email_list'+ count + '" value ="'+count+'" /><br>';
$('#here_emails').append( $(emails[count]).focus() );
count++;
});
最佳答案
将元素添加到页面后,尝试使其聚焦:
$(emails[count])
.appendTo($('#here_emails'))
.focus();
奖励:
[]
:var emails = [];
push()
方法,而不是增加自己的索引变量:emails.push(...);
关于javascript - 将DIV聚焦在DIV阵列之外,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8510980/