码迷,mamicode.com
首页 > Web开发 > 详细

夺命雷公狗jquery---10小实例-表格插入内容

时间:2015-10-23 06:46:00      阅读:203      评论: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.获取表单元素值
                    var hang = $(#hang).val()-1;
                    var lie = $(#lie).val()-1;
                    var content = $(#content).val();
                    //2.通过层次选择器获取表格元素
                    $(tr:eq(+hang+)>td:eq(+lie+)).html(content);
                    
                    
                    
                }
            }
        </script>
    </head>
    <body>
        <table border="1" width="800">
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
        </table>
        <hr />
        cols:<input type="text" id="hang">
        <hr />
        rows:<input type="text" id="lie">
        <hr />
        content:<textarea id="content"></textarea>
        <hr />
        <input type="button" id="btnok" value="录入" />
    </body>
</html>

 

夺命雷公狗jquery---10小实例-表格插入内容

标签:

原文地址:http://www.cnblogs.com/leigood/p/4903335.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!