HTML DIV在TD内部作为href的

时间:2012-08-30 16:02:04

标签: javascript jquery html

大家好我想制作div我在我的td中扮演href的角色。我怎么能实现这个?

如果没有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>

2 个答案:

答案 0 :(得分:3)

使用jquery,您可以执行以下操作:

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

但如果你想要链接,那么你应该使用<a href="...">。这就是他们的目标。 :P

答案 1 :(得分:1)

答案是你没有。

使用html记住的一个重要规则是为您要执行的工作使用正确的元素。这就是为什么存在这样一系列元素的原因。

你开始搞乱切换元素时,你会打开一堆蠕虫,不仅具有跨浏览器兼容性,而且具有可访问性。

使用HTML Anchor元素。您可以按照自己喜欢的方式设置样式,如果需要,可以使用JavaScript轻松覆盖默认行为。有关Anchor元素的更多信息,请查看包含here的信息。