夺命雷公狗jquery---10小实例-表格插入内容
<!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> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </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>