siblings()

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        .even {
            background: #FFF38F;
        }

        .odd {
            background: #FFFFEE;
        }
    </style>
</head>
<body>
    <table>
        <thead>
            <tr><th>姓名</th><th>性别</th><th>暂住地</th></tr>
        </thead>
        <tbody>
            <tr><td>张三</td><td>男</td><td>浙江杭州</td></tr>
            <tr><td>李四</td><td>女</td><td>浙江宁波</td></tr>
            <tr><td>王五</td><td>男</td><td>浙江温州</td></tr>
            <tr><td>赵六</td><td>男</td><td>浙江杭州</td></tr>
        </tbody>
    </table>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("tbody>tr:odd").addClass("odd");
            $("tbody>tr:even").addClass("even");
            $("tr:contains('王五')").addClass("selected");
            $("tbody>tr").click(function () {
                $(this).addClass("selected").siblings().removeClass("selected").end().find(':radio').attr("checked", true);
            });
        });
    </script>
</body>
</html>

posted @ 2016-06-28 15:55  Chris_在IT道路上前行  阅读(165)  评论(0编辑  收藏  举报