1

id="menu_list_comparisons" のテーブルがあります

名前用と言語用の 2 つの入力フィルターがあります。

名前を検索しようとすると、うまくいきます。

言語を検索しようとすると、うまくいきます。

ミックスが必要な場合は機能しません。

<script>
$(document).ready(function(){
//function to filter the results by name
$("#kwd_search").keyup(function(){
    var word=$(this).val()
    if( word != ""){
        $("#menu_list_comparisons tbody>tr").hide();
        $("#menu_list_comparisons td").filter(function(){
               return $(this).text().toLowerCase().indexOf(word ) >-1
        }).parent("tr").show();
    }
    else{
        $("#menu_list_comparisons tbody>tr").show();
    }
    return false;
});


//function to filter the results by lang
$("#kwd_search_lang").keyup(function(){
    var word=$(this).val()
    if( word != ""){
        $("#menu_list_comparisons tbody>tr").hide();
        $("#menu_list_comparisons td").filter(function(){
               return $(this).text().toLowerCase().indexOf(word ) >-1
        }).parent("tr").show();
    }
    else{
        $("#menu_list_comparisons tbody>tr").show();
    }
    return false;
});
});

</script>
<div style="width: 100%; text-align: center;"><br /><label for="kwd_search">Search:</label> <input type="text" id="kwd_search" value=""><label for="kwd_search_lang">Language:</label> <input type="text" id="kwd_search_lang" value=""></div>
4

1 に答える 1

0

コンマを使用してセレクターを区切ります

$("#kwd_search, #kwd_search_lang").keyup(function() {

使用することもできます.add

$("#kwd_search").add( $("#kwd_search_lang")).keyup(function() {

コード

$(document).ready(function () {
    $("#kwd_search, #kwd_search_lang").keyup(function () {
        var word = $(this).val()
        if (word != "") {
            $("#menu_list_comparisons tbody>tr").hide();
            $("#menu_list_comparisons td").filter(function () {
                return $(this).text().toLowerCase().indexOf(word) > -1
            }).parent("tr").show();
        } else {
            $("#menu_list_comparisons tbody>tr").show();
        }
        return false;
    });
});
于 2013-06-13T17:38:53.393 に答える