javascript - TD a href 内的 HTML DIV

标签 javascript jquery html

大家好,我想让 td 中的 div 充当 href 的 Angular 色。我怎样才能实现这个目标?

如果不使用 html,也许可以使用 jquery 或 javascript?

<table class="mgmtview_table" align="center">
    <tr>
    <td class="content" id="content">
       <table class="content_table">
       <tr>
         <td class="topBar">
       <div id="div_view" align="center">FusionCharts will load here!</div> 

    </td> 
        <td class="topBar">
        <div id="div_view2" align="center">FusionCharts will load here!</div> 
    </td> 
        <td class="topBar">
        <div id="div_view3" align="center">FusionCharts will load here!</div> 
    </td> 
    </tr>

        <tr>
         <td class="topBar">
         <div id="div_view4" align="center">FusionCharts will load here!</div> 
    </td> 
    <td class="topBar">
         <div id="div_view5" align="center">FusionCharts will load here!</div> 
    </td> 
    <td class="topBar">
         <div id="div_view6" align="center">FusionCharts will load here!</div> 
    </td> 
    </tr>

        <tr>
         <td class="topBar">
         <div id="div_view7" align="center">FusionCharts will load here!</div> 
    </td> 
    <td class="topBar">
         <div id="div_view8" align="center">FusionCharts will load here!</div> 
    </td> 
    <td class="topBar">
         <div id="div_view9" align="center">FusionCharts will load here!</div> 
    </td> 
    </tr>

最佳答案

使用jquery你可以做这样的事情:

$('table.content_table td div').click(function(){
    alert('clicked');
    location.href='http://google.com';
});

但是如果你想要链接,那么你真的应该使用 <a href="..."> 。这就是它们的用途。 :p

关于javascript - TD a href 内的 HTML DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12201004/

相关文章:

javascript - 为什么在处理数组中的第二个以上索引后,单击如果检查会出现故障

javascript - 在 URL 栏中按下 ENTER 时如何更正 Firefox 中的#anchor 滚动位置

javascript - 使用 jQuery 获取 iframe 的 HTML 内容

html - 单页应用程序 (SPA) 中的命名 anchor

javascript - 双击 Facebook 分享按钮

Javascript 防止在浏览器窗口外拖放

javascript - 调整文本区域的事件大小?

javascript - 如何使 Youtube 上的视频不遮盖灯箱?

javascript - "New Feature"用户指标覆盖

jquery - 带有 jquery mobile 的全宽水平按钮?