0

宿泊施設セクションのページのさまざまなパラメーターに基づいてフィルター処理するページを取得しようとしています。ただし、フィルターを連携させることはできないため、ユーザーが 1 つのセクションをクリックすると、他のセクションと連携します。

フィドルはhttp://jsfiddle.net/ktcle/YEtgM/2/です

助けてくれてありがとう

$('input').change(function(){
$('input').each(function(){
    var checked = $(this).attr('checked') || false;
    var numberofrooms = $(this).data('bedrooms');
    var sitelocation = $(this).data('location');
    $('li').each(function(){
        if ($(this).data('bedrooms')==numberofrooms){
            checked ? $(this).show() : $(this).hide();
        }

        if ($(this).data('location')==sitelocation){
            checked ? $(this).show() : $(this).hide();
        }

    });
});

});

4

1 に答える 1

0

このjsFiddleの例のようなものはどうですか?

いくつかの理由で入力値を指定しましたが、jQuery は次のとおりです。

$('input').change(function() {
    var room_array = new Array(),
        loc_array = new Array();
    $('.br').each(function() {
        if ($(this).is(':checked')) {
            room_array.push($(this).data('bedrooms'));
        }
    });
    $('.loc').each(function() {
        if ($(this).is(':checked')) {
            loc_array.push($(this).data('location'));
        }
    });
    $('li').each(function() {
        if ($.inArray($(this).data('location'), loc_array) > -1 && $.inArray($(this).data('bedrooms'), room_array) > -1) {
            $(this).show();
        } else {
            $(this).hide();
        }
    });
});​
于 2012-07-03T16:22:42.023 に答える