jQuery 获取 class 为 xuanze 的父 div 下 input 的 value 并循环获取子 div 的 i 值
$(function() { var daanArray = [];
$('input.xuanze').click(function(e) { $(this).toggleClass('redBorder');
var value = $(this).parent().find('input').val();
var id = $(this).attr('i');
var daan = $(this).attr('value');
daanArray.push({ daan: daan, id: id });
console.log(daanArray);
$.ajax({
type: 'POST',
url: '{:url("Dati/getAnswer")}',
data: { daan: daanArray },
dataType: 'json',
success: function(msg) {
console.log('成功');
}
});
}); });
原文地址: https://www.cveoy.top/t/topic/o40Q 著作权归作者所有。请勿转载和采集!