jquery的这个each遍历怎么做啊?

这个判断怎么让他随着每次遍历下移啊。要不然每次判断都是用第一个值判断。求大神,谢谢

$(document).ready(function() {
    var trs = $("tbody>tr");
    $("input").click(function() {
        trs.children("td:eq(5):contains('通识必修')").show();
        trs.children("td:eq(5):not(contains('通识必修'))").hide();
    });
});

追问

不可以的。因为我是一个按钮要控制多个的。

是这个样子的。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-09-22
$("tbody > tr").each(function(){
    if($(this).children("td:eq(5)").text()=="通识必修"){
        $(this).show();
    }else{
        $(this).hide();
    }
});

each里头用this就行了,这个就能代表每个tr。

追问

哦。可以了。谢谢啊。

本回答被提问者采纳