I'm working on a project for school where I need to make a product selector using jquery! It worked fined with my code ( http://jsfiddle.net/rda9Q/6/ ) and the checkbox were working, it was all automatic and good, until I tried to use drop-down lists! Surely because I have no idea how to make my code react after the value is changed or something...
The code that I need to reproduce so that it react on value changing in the list:
$('.filtercondition:checked').each(function(){
className += $(this).attr('value');
});
I just need to keep the automatism and the order and value. All I need is the part that will also react on value changing in drop-down lists because I will add some elements after!
Thank you beforehand for future help! :)
Try
$('.filtercondition').change(function () {
var className = '';
$('.filtercondition[type="checkbox"]:checked').each(function () {
className += this.value;
});
className += $('select.filtercondition').val();
if (className.length == 0) className = 'mainresult';
$('.results').hide();
$('#' + className).show();
});
Demo: Fiddle
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.