jQuery实现点击表格单元格就可以编辑内容的方法

        $('table td').click(function(){
            if(!$(this).is('.input')){
                $(this).addClass('input').html('<input type="text" value="'+ $(this).text() +'" />').find('input').focus().blur(function(){
                $(this).parent().removeClass('input').html($(this).val() || 0);
                });
            }
        }).hover(function(){
            $(this).addClass('hover');
        },function(){
            $(this).removeClass('hover');
        });

 

posted @ 2017-10-13 14:21  珈子  阅读(1879)  评论(0编辑  收藏  举报