1
我期待采取如下:这些组合成一个功能 - 即做同样的事情 - jQuery的
$('.formWrapper').on('change', 'select', function(){
data[$(this).attr('name')] = $(this).val();
console.log(data);
});
$('.formWrapper').on('change', 'input', function(){
data[$(this).attr('name')] = $(this).val();
});
并将其转换成一个功能它都手表和input
... select
会是什么最简单的方法来做到这一点?
我不知道你可以做“ATTR,ATTR,...” – TheWebs
@TheWebs:逗号,您可以将多个选择到一个:http://api.jquery.com/multiple-selector/ –
你可以将它们加上逗号分隔,所有你的选择器 – Bhadra