javascript - 读取 <td> 然后在单击时加载弹出窗口

标签 javascript jquery

我想通过嵌入隐藏的 <td> 使表格行完全可点击包含如下链接:

<tr class="simplehighlight junk" >
  <td>07/09/2011</td>
  <td>Jennifer Woods Memorial GP</td>
  <td>A52</td>
  <td>Harris, Fred</td>
  <td>1900</td>
  <td>Nikolayev, Igor</td>
  <td>2395</td>
  <td class="text-center">0-1</td>
  <td style='display:none;visibility:hidden;\'> games/game1242.php </td>
</tr>

我使用 colorbox 来定位表格单元格,如下所示:

<!--colorbox-->
<script src="./js/jquery.colorbox-min.js"></script>
<script>
  $('tr.junk').colorbox(
    {
      iframe:true,
      transition:'elastic',
      speed:'100',
      width:1030,
      height:550,
      href: function(){
        return $(this).find('td').eq(8).text();
      }
    }
  );
</script>

但是我想使用jquery:

<!--Another Pop-up for games table-->
<script src="./js/jquery.popupWindow-min.js" ></script> 
<script>
  $('.diagram-popup').popupWindow({centerBrowser:1, height:560, width:1024});
</script> 

如何添加类(class) diagram-popup到第 8 个表数据单元格并让该行在单击时读取该单元格的内容?

最佳答案

<td class='diagram-popup' style='display:none;visibility:hidden;\'> games/game1242.php </td>

$(document).ready(function(){
   $('.diagram-popup').click(function(){
      $(this).html(); //contents of cell
   });
});

这就是你要找的吗?

更新:啊,我明白了...您想要单击该行中的任何单元格,然后获取内容...也许这会有所帮助...

<td style='display:none;visibility:hidden;\'> games/game1242.php </td>

$(document).ready(function(){
   $('table tr td').click(function(){
      var cell = $(this).parent().find('td:last');
      cell.addClass('diagram-popup'); //Not clear on if this is what you're wanting, you can always just print out the diagram-popup class server side 
      cell.html(); //contents of cell
   });
});

我还没有测试过,但它应该可以工作。

关于javascript - 读取 <td> 然后在单击时加载弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7196977/

相关文章:

javascript - Chrome Tab重复项未发出网络请求

javascript - 使用 If 语句检查值的有效方法未在 Javascript 或 JQuery 中使用

Javascript onclick 改变 id img

javascript - RxJs6 - 静态合并可观察数组

javascript - ASP.net OnClientClick 有一个异步调用 - 如何仅在异步调用完成并成功时才继续进行服务器端 OnClick?

javascript - 仅使 div 的折叠部分可点击 - 展开部分应保持不可点击

javascript - 潜在客户发掘的 Facebook webhook - 无法检索 Facebook 潜在客户广告

javascript - 用对象动态填充 div

jquery - Jasmine 中的鼠标事件

jQuery slideDown() 返回 is null 错误