将table中的一列赋值到另一列
2012-06-09 07:02:01 来源:WEB开发网核心提示: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" language="javascript" src="../js/jquery1.4.1.js"></script> <script> $(document).ready(function(){ $("#checkbox_copy").click(function() { $('input[id ^=\'txt_value1\']').each(function(i){ var fontId =$(this).attr('id'); var secondId=fontId.substr(fontId.length-1); $("input[id ^='txt_value2"+secondId+"']").val($(this).val()); }); }); }); </script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <div class="dialog"> <table width="200" border="1" cellspacing="0"> <tr> <td>id</td> <td>value1</td> <td>value2</td> </tr> <tr> <td>1</td> <td><input name="txt_value11" type="text" id="txt_value11" value="xx" /></td> <td> <input type="text" name="txt_value11" id="txt_value21" /></td> </tr> <tr> <td>2</td> <td><input name="txt_value11" type="text" id="txt_value12" value="yy" /></td> <td> <input type="text" name="txt_value11" id="txt_value22" /></td> </tr> <tr> <td>3</td> <td><input name="txt_value11" type="text" id="txt_value13" value="zz" /></td> <td> <input type="text" name="txt_value11" id="txt_value21" /></td> </tr> <tr> <td>4</td> <td><input name="txt_value11" type="text" id="txt_value14" value="ww" /></td> <td> <input type="text" name="txt_value11" id="txt_value21" /></td> </tr> </table> <input type="checkbox" name="checkbox_copy" id="checkbox_copy" /> <label for="checkbox_copy">value1 copy to valu2</label> </div> </body> </html>
更多精彩
赞助商链接