开发者社区> 问答> 正文

关于jquery点击右侧用户名将值写到左侧表单问题

screenshot
左侧表单代码

 <table class="table-en">
                        <tbody><tr><th colspan="7">报名信息</th>
                        </tr></tbody><tbody>
                                            <tr>
                        <td class="round" width="60">第1场&nbsp;&nbsp;&nbsp;&nbsp;男单</td>
                        <td colspan="5">
                                                <div class="enline">
                        <input size="10" name="user_180[]" class="username" id="user_180_1" value="" type="text">
                        <span name="age" class="age">26</span>
                        <span name="sex" class="sex">男</span>
                        <span name="point" class="point">12000</span>
                        <span name="level" class="level">武士</span>
                        <span name="card" class="card"></span>
                        </div>
                                                </td>
                        </tr>
                                                <tr>
                        <td class="round" width="60">第2场&nbsp;&nbsp;&nbsp;&nbsp;男单</td>
                        <td colspan="5">
                                                <div class="enline">
                        <input size="10" name="user_181[]" class="username" id="user_181_1" value="" type="text">
                        <span name="age" class="age">26</span>
                        <span name="sex" class="sex">男</span>
                        <span name="point" class="point">12000</span>
                        <span name="level" class="level">武士</span>
                        <span name="card" class="card"></span>
                        </div>
                                                </td>
                        </tr>
                                                <tr>
                        <td class="round" width="60">第3场&nbsp;&nbsp;&nbsp;&nbsp;90男双</td>
                        <td colspan="5">
                                                <div class="enline">
                        <input size="10" name="user_182[]" class="username" id="user_182_1" value="" type="text">
                        <span name="age" class="age">26</span>
                        <span name="sex" class="sex">男</span>
                        <span name="point" class="point">12000</span>
                        <span name="level" class="level">武士</span>
                        <span name="card" class="card"></span>
                        </div>
                        <div class="enline">
                        <input size="10" name="user_182[]" class="username" id="user_182_2" value="" type="text">
                        <span name="age" class="age">26</span>
                        <span name="sex" class="sex">男</span>
                        <span name="point" class="point">12000</span>
                        <span name="level" class="level">武士</span>
                        <span name="card" class="card"></span>
                        </div>
                                                </td>
                        </tr>
                                                <tr>
                        <td class="round" width="60">第4场&nbsp;&nbsp;&nbsp;&nbsp;男单</td>
                        <td colspan="5">
                                                <div class="enline">
                        <input size="10" name="user_183[]" class="username" id="user_183_1" value="" type="text">
                        <span name="age" class="age">26</span>
                        <span name="sex" class="sex">男</span>
                        <span name="point" class="point">12000</span>
                        <span name="level" class="level">武士</span>
                        <span name="card" class="card"></span>
                        </div>
                                                </td>
                        </tr>
                                                <tr>
                        <td class="round" width="60">第5场&nbsp;&nbsp;&nbsp;&nbsp;男单</td>
                        <td colspan="5">
                                                <div class="enline">
                        <input size="10" name="user_184[]" class="username" id="user_184_1" value="" type="text">
                        <span name="age" class="age">26</span>
                        <span name="sex" class="sex">男</span>
                        <span name="point" class="point">12000</span>
                        <span name="level" class="level">武士</span>
                        <span name="card" class="card"></span>
                        </div>
                                                </td>
                        </tr>
                                                </tbody>
                        </table>

右侧表单代码

 <table class="table-left" id="ulist">
                        <thead>
                            <tr>
                            <th>用户名</th>
                            <th>性别</th>
                            <th>年龄</th>
                            <th>等级</th>
                            </tr>
                        </thead>
                        <tbody>

                            <tr>
                            <td class="iputuser" data-userid="15" data-username="秋天" data-old="28" data-sex="男" data-point="6720" data-card="430124198608252536" data-rating="武士"><img src="/themes/feiyu/images/isreal.png" style="vertical-align:middle" height="12" width="12">秋天</td>
                            <td>男</td>
                            <td>28</td>
                            <td>武士</td>
                            </tr>

                            <tr>
                            <td class="iputuser" data-userid="20" data-username="南方" data-old="28" data-sex="男" data-point="6720" data-card="430124198608242538" data-rating="武士"><img src="/themes/feiyu/images/isreal.png" style="vertical-align:middle" height="12" width="12">南方</td>
                            <td>男</td>
                            <td>28</td>
                            <td>武士</td>
                            </tr>

                            <tr>
                            <td class="iputuser" data-userid="19" data-username="东方" data-old="28" data-sex="男" data-point="6720" data-card="430281198610154054" data-rating="武士"><img src="/themes/feiyu/images/isreal.png" style="vertical-align:middle" height="12" width="12">东方</td>
                            <td>男</td>
                            <td>28</td>
                            <td>武士</td>
                            </tr>

                            <tr>
                            <td class="iputuser" data-userid="17" data-username="夏天" data-old="28" data-sex="女" data-point="6720" data-card="430124198608242538" data-rating="武士"><img src="/themes/feiyu/images/isreal.png" style="vertical-align:middle" height="12" width="12">夏天</td>
                            <td>女</td>
                            <td>28</td>
                            <td>武士</td>
                            </tr>

                            <tr>
                            <td class="iputuser" data-userid="74" data-username="星沙" data-old="" data-sex="男" data-point="3600" data-card="" data-rating="师兄"><img src="/themes/feiyu/images/isreal.png" style="vertical-align:middle" height="12" width="12">星沙</td>
                            <td>男</td>
                            <td></td>
                            <td>师兄</td>
                            </tr>

                            <tr>
                            <td class="iputuser" data-userid="61" data-username="李八" data-old="28" data-sex="男" data-point="6720" data-card="430124198608242538" data-rating="武士"><img src="/themes/feiyu/images/isreal.png" style="vertical-align:middle" height="12" width="12">李八</td>
                            <td>男</td>
                            <td>28</td>
                            <td>武士</td>
                            </tr>

                            <tr>
                            <td class="iputuser" data-userid="69" data-username="孙六" data-old="" data-sex="男" data-point="3240" data-card="" data-rating="师兄"><img src="/themes/feiyu/images/isreal.png" style="vertical-align:middle" height="12" width="12">孙六</td>
                            <td>男</td>
                            <td></td>
                            <td>师兄</td>
                            </tr>

                            <tr>
                            <td class="iputuser" data-userid="73" data-username="孙十" data-old="" data-sex="男" data-point="2880" data-card="" data-rating="学徒"><img src="/themes/feiyu/images/isreal.png" style="vertical-align:middle" height="12" width="12">孙十</td>
                            <td>男</td>
                            <td></td>
                            <td>学徒</td>
                            </tr>

                        </tbody>
                        </table>

展开
收起
吴孟桥 2016-06-01 15:42:23 2108 0
1 条回答
写回答
取消 提交回答
  • 简单写了一个,你试试。

     <!DOCTYPE html>
    <html>
     <head> 
      <meta charset="utf-8" /> 
      <title>img</title> 
      <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> 
     </head> 
     <body> 
      <table class="table-en"> 
       <tbody>
        <tr>
         <th colspan="7">报名信息</th> 
        </tr>
       </tbody>
       <tbody id="infotable"> 
        <tr> 
         <td class="round" width="60">第1场&nbsp;&nbsp;&nbsp;&nbsp;男单</td> 
         <td colspan="5"> 
          <div class="enline"> 
          夏天
           <span name="age" class="age">26</span> 
           <span name="sex" class="sex">男</span> 
           <span name="point" class="point">12000</span> 
           <span name="level" class="level">武士</span> 
           <span name="card" class="card"></span> 
          </div> </td> 
        </tr> 
       </tbody> 
      </table> 
      <table class="table-en"> 
       <tbody>
        <tr>
         <th colspan="7">报名信息</th> 
        </tr>
       </tbody>
       <tbody> 
         <tr id="user1"> 
         <!-- <td class="round" width="60">第1场&nbsp;&nbsp;&nbsp;&nbsp;男单</td>  -->
         <td colspan="5"> 
          <div class="enline"> 
            <span onclick="addinfo('user1')">夏天1111111111111111</span>
           <span name="age" class="age">26</span> 
           <span name="sex" class="sex">男</span> 
           <span name="point" class="point">12000</span> 
           <span name="level" class="level">武士</span> 
           <span name="card" class="card"></span> 
          </div> </td> 
        </tr> 
       </tbody> 
      </table>  
      <script type="text/javascript">
    
        function addinfo(user) {
            var html=$("#"+user).html();
            //你可以在这里设置第几场等信息.
            html='<tr>'+html+'</tr>';
            $("#infotable").append(html);
        }
    
    </script> 
     </body>
    </html>
    2019-07-17 19:23:26
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关课程

更多

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载