我希望点击#value(VALUE)
后使用input:checkbox
获取值.serialize()
?
示例: http://jsfiddle.net/tKBJ2/40/
$('#value').click(function(e){
e.preventDefault();
alert("this alert only after click on '#value'");
$('.table_show tr').each(function(){
if ($(this).prop('checked')) {
var dataString = $('.table_show').serialize(); // This don't work
alert(dataString);
$(this).parent().parent().fadeOut("slow");
$.ajax({
type: "POST",
url: "http://localhost/admin/customer_size/delete",
data: dataString,
cache: false,
success: function(){
},
error: function(data){
alert('Load was performed.');
}
})
}
})
});
答案 0 :(得分:1)
serialize()
用于从表单的输入中获取查询字符串,您应该检查选择器是否选择表单元素。
cf jquery doc:http://api.jquery.com/serialize/
将您的div table
_ show封装在form
中,并对此form
进行序列化:
<form class="myForm">
<div class="table_show">
rest of your code
</div>
</form>
然后在你的js:
var dataString = $('.myForm').serialize();