2015-10-06 45 views
0

如果这是一个数组,我不知道如何触发输入。输入数组的JQuery事件

我可以读取值,但我不知道什么是使事件的输入。

$('input[name^="months"]').change(function() { 
alert($(this).val()); 
}); 

<input type="text" name="months[january]" value="100"> 
<input type="text" name="months[february]" value="150"> 

谢谢。

回答

2

的变化()函数包括event

$('input[name^="months"]').change(function(event) { 
    console.log(event.target); 
    alert($(this).val()); 
}); 
+0

那你知道拿到一个月(1月)一个简单的方法,而不是分析所有文字,因为我的输出是这样的。 Amador

+0

您的意思是将值那个文本框?是'$(this).val()'不工作? – stackoverfloweth