Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么来自动态添加输入的输入名称的最近索引不起作用?_Javascript_Php_Jquery_Html_Dynamic - Fatal编程技术网

Javascript 为什么来自动态添加输入的输入名称的最近索引不起作用?

Javascript 为什么来自动态添加输入的输入名称的最近索引不起作用?,javascript,php,jquery,html,dynamic,Javascript,Php,Jquery,Html,Dynamic,我有一个表单,我有动态添加的输入,我有动态添加的每个输入的变更索引 这是我的html表单 $(函数(){ var hobiesIndex=1; $(“#添加_字段”)。单击(函数(){ $(this).closest('tr').find('input.hobies').attr('name'),“hobies['”+hobiesIndex+“')”); $(“#table_container”).append($(“#temp_div”).html()); hobiesIndex++; })

我有一个表单,我有动态添加的输入,我有动态添加的每个输入的变更索引

这是我的html表单

$(函数(){
var hobiesIndex=1;
$(“#添加_字段”)。单击(函数(){
$(this).closest('tr').find('input.hobies').attr('name'),“hobies['”+hobiesIndex+“')”);
$(“#table_container”).append($(“#temp_div”).html());
hobiesIndex++;
});
})

我的恐惧
形象

+添加更多


针对每次单击中的最后一次
输入

改变

$(this).closest('tr').find('input.hobies').attr('name', "hobies['"+hobiesIndex+"']");


你们想要什么,发生了什么?谢谢你们的回答,这正是我想要的,我不知道什么时候我想用它last@Sai,非常欢迎。选择器没有在代码中针对正确的元素。。。。。
$('input.hobies').last().attr('name', "hobies["+hobiesIndex+"]");