doukeng1922 2015-02-20 08:54
浏览 31
已采纳

想要在jquery中显示表中特定行的文本框

I want to display the text box and its update button for which the row I click to edit my value.

enter image description here

In the above image When I click edit discount to change the discount value for the booking id 6, it shows all the text boxes in all rows like

enter image description here

<table id="example1" class="table table-bordered table-striped">
         <td><?php echo $bookedrow['status'];?></td>
       <td class="discount_val"><?php echo $bookedrow['discount'];?></td>
       <td class="new_discount">
         <input type="text" name="new_discount"/>
          <input class="btn btn-primary" id="update" name="update" value="Update" type="submit"/>
        </td>
       <td><a href="#" class="edit_discount">Edit discount</a></td>
            </tr>
               </tbody>
        </table>

JS code:

       $('.new_discount').hide();   
 $('.edit_discount').click(function(){
    $('.discount_val').hide(); 
    $('.new_discount').show();

 });

Now i want to get the text box and its button for which I'm selecting to update and that value will update for that particular id only.Guide me!!

  • 写回答

4条回答 默认 最新

  • douqu2712 2015-02-20 08:58
    关注

    You need to use DOM traversal functions to find just the element in the current row:

    $('.edit_discount').click(function() {
        var row = $(this).closest("tr");
        row.find(".discount_val").hide();
        row.find(".new_discount").show();
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?