1.请帮我把下边js转换成jquery2.在遍历的时候,我先判断表格下边的checkbox是否被选中,是不是下边这么写
if(  $().find(":checkbox").is(':checked'))
{}
function table_hover_color(){
    var rows = document.getElementsByTagName('tr'); 
    for (var i = 0; i < rows.length; i++) {
        rows[i].onmouseover = function () {
            this.className += 'row_bg'; 
        }
        rows[i].onmouseout = function () {
            this.className = this.className.replace('row_bg', '');
        }
    };
}

解决方案 »

  1.   

    $("input[type=checkbox]:checked")这个直接把选中的全取到了,不用判断了 。选择器很灵活的 ,有很多选取方法的,根据你的需要写不同的选择器。
      

  2.   

    <script type="text/javascript">
        //1.请帮我把下边js转换成jquery
        function table_hover_color(){
            $("tr").hover(function(){
                $(this).addClass("row_bg");
            },function(){
                $(this).removeClass("row_bg");
            })
        }
        //2.在遍历的时候,我先判断表格下边的checkbox是否被选中,是不是下边这么写
        if( $(this).find("input[type='checkbox']").is(':checked')){}
    </script>