Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.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_Jquery_Custom Data Attribute - Fatal编程技术网

Javascript 如何在多个选择输入中获取数据属性?

Javascript 如何在多个选择输入中获取数据属性?,javascript,jquery,custom-data-attribute,Javascript,Jquery,Custom Data Attribute,$('select.dates').change(函数(){ $(this.closest('tr').find('input.numValue').val($(this.options[this.selectedIndex]).attr('data-value')); }); 函数addnewrow() { var n=($('.table tr')。长度-0)+1; var tr=''+ '选择Value1Value2Value3'+ ''+ ''; $('.detail')。追加(

$('select.dates').change(函数(){
$(this.closest('tr').find('input.numValue').val($(this.options[this.selectedIndex]).attr('data-value'));
});
函数addnewrow()
{  
var n=($('.table tr')。长度-0)+1;
var tr=''+
'选择Value1Value2Value3'+
''+
'';  
$('.detail')。追加(tr);
}
$('#添加')。单击(函数()
{
addnewrow();
});

选择
价值
选择
价值1
价值2
价值3
选择
价值1
价值2
价值3
选择
价值1
价值2
价值3

要获取下一个
输入,请选择使用
$(this).next('input.numValue')

$('select.dates').change(函数(){
$(this.next('input.numValue').val($(this.options[this.selectedIndex]).attr('data-value'));
});

1/1/11
1/2/11
1/3/11
1/1/11
1/2/11
1/3/11

非常感谢,但当我在表中尝试此代码时,它不是run@MaherAdelSultan此代码与您提供的代码一起运行。。您需要为表提供代码,以便让我看到整个过程picture@MaherAdelSultan无论如何,让我假设一列上的
选择
,另一列上的
输入
。。在这种情况下,您需要使用
$(this).closest('tr').find('input.numValue')
非常感谢。您完全欢迎@MaherAdelSultan。。祝你今天愉快:-)