duanqin7791 2014-09-10 05:14
浏览 36

Jquery单击按钮显示内容

Using Jquery,I want to show the content on a element when a button is clicked.In each column there are buttons.When I click ,corresponding content should be displayed when I click on the button.

1.This is code block

  <html>
     <body>
       <table>
          <tr>
             <td><div><button type="button" class="addButton">

Show

       </table>
     </body>

2.Scripting Code

<script type="text/javascript">

$(document).ready(function(){ 
  $(".addButton").click(function(event){
       var tdCount=$("#addInf.addInfo").length;
       //length of the td elements
       alert(tdCount);

       for(var $i=0;$i<tdCount;$i++){
           alert($i);
           $(".addButton:eq(0)").hide(); 
          // $(".addButton:eq($i)").hide(); 

//not able to hide for ith elements

        }                                
    });     
});  

My problem is first element is hidden.I want to dynamically show content of first column td and second columns td and so on //when a button is clicked and hide the button as well Iam able to do for one td element hide and show content.But how to do it dynamically

  • 写回答

2条回答 默认 最新

  • doumeng3345 2014-09-10 05:32
    关注

    The context of the button click event handler is the button itself. In order to hide it you can simply do:

    $(this).hide();
    
    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了