首页 > Web开发 > 详细

夺命雷公狗jquery---3普通选择器

时间:2015-10-18 23:02:18      阅读:275      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="js/jquery.js"></script>
        <script>
            window.onload = function(){
                document.getElementById(btnok).onclick = function(){
                    //1.匹配第一个单元格
                    //$(‘td:first‘).html(‘test‘);
                    //2.匹配最后一个单元格
                    //$(‘td:last‘).html(‘test‘);
                    //3.通过odd和even实现隔行变色
                    //$(‘td:odd‘).css(‘backgroundColor‘,‘red‘);
                    //4.匹配索引为5的单元格
                    //$(‘td:eq(5)‘).css(‘backgroundColor‘,‘red‘);
                    //5匹配索引大于5的所有单元格
                    //$(‘td:gt(5)‘).css(‘backgroundColor‘,‘red‘);
                    //6.匹配索引小于5的所有单元格
                    //$(‘td:lt(5)‘).css(‘backgroundColor‘,‘red‘);
                    //7.匹配除索引5以外的所有td元素
                    $(td:not(td:eq(5))).css(backgroundColor,red);
                }
            }
        </script>
    </head>
    <body>
        <input type="button" id="btnok" value="匹配" />
        <br/>
        <table width="800" border="1">
            <tr>
                <td>0</td>
                <td>1</td>
                <td>2</td>
                <td>3</td>
                <td>4</td>
                <td>5</td>
                <td>6</td>
                <td>7</td>
                <td>8</td>
                <td>9</td>
            </tr>
        </table>
    </body>
</html>

 

夺命雷公狗jquery---3普通选择器

原文:http://www.cnblogs.com/leigood/p/4890517.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!