Javascript 阅读<;td>;然后单击时加载弹出窗口

Javascript 阅读<;td>;然后单击时加载弹出窗口,javascript,jquery,Javascript,Jquery,我想通过嵌入一个隐藏的使表行完全可点击,其中包含如下链接: <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> &l

我想通过嵌入一个隐藏的
使表行完全可点击,其中包含如下链接:

<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>

07/09/2011
詹妮弗·伍兹纪念家庭医生
A52
哈里斯,弗雷德
1900
尼古拉耶夫,伊戈尔
2395
0-1
games/game1242.php
我使用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>

$('tr.junk').colorbox(
{
伊夫拉姆:是的,
过渡:'弹性',
速度:'100',
宽度:1030,
身高:550,
href:function(){
返回$(this.find('td').eq(8.text();
}
}
);
但我想使用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> 

$('.diagram popup').popupWindow({centerBrowser:1,高度:560,宽度:1024});
如何将类<代码>图表弹出窗口添加到第8个表格数据单元格,并在单击该行时读取该单元格的内容

games/game1242.php
<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
   });
});
$(文档).ready(函数(){ $('.diagram popup')。单击(函数(){ $(this.html();//单元格的内容 }); });
这就是你要找的吗

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

<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
   });
});
games/game1242.php
$(文档).ready(函数(){
$('table tr td')。单击(函数(){
var cell=$(this.parent().find('td:last');
cell.addClass('diagram-popup');//不清楚这是否是您想要的,您始终可以在服务器端打印出diagram-popup类
cell.html();//单元格的内容
});
});

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

如果您想在可单击的行中添加一个类,我可能会将相关的
tr
更改为如下内容:

<tr class="simplehighlight junk diagram-popup" data-href="games/game1242.php" >

我会完全放下你隐藏的
,这是不必要的

以及jquery:

<script src="./js/jquery.popupWindow-min.js" ></script> 
<script type='text/javascript'>
  $(function(){
    $('.diagram-popup').click(function(e){
      $(this).popupWindow({
        windowURL: $(this).data('href'),
        centerBrowser: 1,
        height: 560,
        width: 1024
      });
    });
  });
</script>

$(函数(){
$('.diagram popup')。单击(函数(e){
$(此).弹出窗口({
windowURL:$(this).data('href'),
centerBrowser:1,
身高:560,
宽度:1024
});
});
});
我不太喜欢在我点击东西的时候弹出窗口……我认为这并不能提供一个好的用户体验。但每个人都有自己的


这里有一个JSFIDLE作为概念证明:

它不起作用。也许有人可以查一下DW的来源。。。并破坏数据表。这是DataTables运行的原始版本:基于您的建议(我非常感谢您的努力)的新版本在这里:嗯,在您的源代码中,我看到两个对popupWindow的调用,一个是我的,另一个是没有url的旧版本。可能应该只使用一个?如果我的答案对你有用,你也应该接受它,因为它是正确的:)我刚刚注释掉了另一个弹出窗口,它仍然是DW。我几乎准备好接受你的建议,放弃“行点击”的想法,添加一个简单的加载游戏分数。嗯,没有看到你尝试使用的代码,我看不出你做错了什么,看起来你已经更改了(抱歉!)