要从范围滑块获取值并将其传递给 jQuery,您可以使用 oninput 事件将事件侦听器添加到滑块元素:
function filterProducts() {
var myCheckboxes = new Array();
$("input[name='types[]']:checked").each(function() {
myCheckboxes.push($(this).val());
});
var minPrice = $('.tm-rangeslider').data('cur_min');
var maxPrice = $('.tm-rangeslider').data('cur_max');
$.ajax({
url: '<?php echo base_url()?>homecontroller/filterpt',
type: 'POST',
data: {
id: <?=$idz?>,
types: myCheckboxes,
minPrice: minPrice,
maxPrice: maxPrice
},
error: function() {
alert('Something is wrong');
},
success: function(data) {
var count = $('.myth').length;
$('#marble').html(data);
$('#count').html(count);
}
});
}
$(document).ready(function() {
$('[name="types[]"]').click(function() {
filterProducts();
});
// add event listener to range slider
$('.tm-rangeslider').on('input', function() {
filterProducts();
});
});