标签:
<!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>
标签:
原文地址:http://www.cnblogs.com/leigood/p/4903335.html