doumuyu0837 2014-03-19 20:23
浏览 33
已采纳

选择特定表行时禁用按钮

I want to disable a particular row button and not all the buttons. I tried using id but it only hide the very first row button. Any help would be nice.

php:

$rowID=1;
while($row = oci_fetch_array($query))
{
  echo '<tr>

  <td>
      <a href="#" rel='.$rowID.' id="buttonq" class="button green ValueDisplay">
            <div class="icon" style="margin-left: 5px; margin-top: 5px;">
                   <span class="ico-edit"></span>
            </div>
      </a>
  </td>

  </tr>';
  $rowID++;
}

js:

<script>
$('.ValueDisplay').click(function()
{
   var getid = this.rel;

   $('#buttonq').css('visibility', 'hidden');
   //document.getElementById('buttonq'+getid+'').style.visibility="hidden";
});
</script>
  • 写回答

2条回答 默认 最新

  • dongqin6926 2014-03-19 20:32
    关注

    As per my comment: You are hiding the clicked element, so just use:

    $('.ValueDisplay').click(function(ev)
    {
        ev.preventDefault();
        //show all buttons
        $('.ValueDisplay').show();
        // hide this one
        $(this).hide();
    });
    

    You may as well remove the id, as it is not valid to have duplicate id's and it does not seem to serve a purpose:

    <td>
      <a href="#" class="button green ValueDisplay">
            <div class="icon" style="margin-left: 5px; margin-top: 5px;">
                   <span class="ico-edit"></span>
            </div>
      </a>
    </td>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于OPENCV的人脸识别
  • ¥20 51单片机学习中的问题
  • ¥30 Windows Server 2016利用兩張網卡處理兩個不同網絡
  • ¥15 Python中knn问题
  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!