Javascript jQuery中的筛选不起作用
我有一个分类的项目列表,希望使用JQuery进行筛选。我正在使用以下代码,但似乎不起作用: HTML:Javascript jQuery中的筛选不起作用,javascript,jquery,Javascript,Jquery,我有一个分类的项目列表,希望使用JQuery进行筛选。我正在使用以下代码,但似乎不起作用: HTML: 有几个错误 $(document).ready(function() { $('.itemage').change(function () { var select_val = $(this).val(); if ($(this).val() == '10') { $('.todo').show(); } els
有几个错误
$(document).ready(function() {
$('.itemage').change(function () {
var select_val = $(this).val();
if ($(this).val() == '10') {
$('.todo').show();
} else {
$('.todo').hide();
$('.todo').filter(function () {
return $(this).attr('itemage') == select_val;
}).show();
}
});
});
@Satpal可以正常工作,但当选择所有项目时,如何让它显示所有项目?
function ($) {
$('.itemage').change(function () {
var select_val = $(this).val();
if ($(this).val() == '10') {
$('li.todo').show();
} else {
$('li.todo').hide();
$('li.todo').filter(function () {
if ($(this).attr('itemage') == select_val) return true;
else return false;
}).show();
} }
})
})(jQuery)
$(document).ready(function() {
$('.itemage').change(function () {
var select_val = $(this).val();
if ($(this).val() == '10') {
$('.todo').show();
} else {
$('.todo').hide();
$('.todo').filter(function () {
return $(this).attr('itemage') == select_val;
}).show();
}
});
});