Javascript HTML DIV';位于TD&x27内的s;s as href';s

Javascript HTML DIV';位于TD&x27内的s;s as href';s,javascript,jquery,html,Javascript,Jquery,Html,大家好,我想让我的td中的div充当href。我怎样才能做到这一点 如果不使用html,可以使用jquery或javascript <table class="mgmtview_table" align="center"> <tr> <td class="content" id="content"> <table class="content_table"> <tr> <

大家好,我想让我的td中的div充当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>

FusionCharts将在这里加载!
FusionCharts将在这里加载!
FusionCharts将在这里加载!
FusionCharts将在这里加载!
FusionCharts将在这里加载!
FusionCharts将在这里加载!
FusionCharts将在这里加载!
FusionCharts将在这里加载!
FusionCharts将在这里加载!

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

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

但是如果你想要链接,那么你应该真正使用
。这就是它们的用途p

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

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

但是如果你想要链接,那么你应该真正使用
。这就是它们的用途答案是你没有

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

一旦你开始胡乱切换元素,你就打开了一罐蠕虫,不仅具有跨浏览器兼容性,而且还具有可访问性


使用HTML锚元素。你可以用任何你喜欢的方式来设计它,如果需要的话,你可以用JavaScript轻松地覆盖默认行为。有关锚元素的更多信息,请查看包含的信息。

答案是您没有

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

一旦你开始胡乱切换元素,你就打开了一罐蠕虫,不仅具有跨浏览器兼容性,而且还具有可访问性


使用HTML锚元素。你可以用任何你喜欢的方式来设计它,如果需要的话,你可以用JavaScript轻松地覆盖默认行为。有关锚元素的更多信息,请查看包含的信息。

为什么不使用标签?我同意Immanish-为什么要这样做?确实如此。可以将其样式设置为
display:block
,使其行为类似于块元素(类似于div),因此可以为其指定宽度,高度和其他属性,就像你现在使用div时所做的那样。根本不需要Javascript。如果你使用合适的标记来达到预期目的,你会更喜欢编程。对投票人来说……不要盲目地投票。OP显然是一个初学者,甚至添加了一个代码示例,也努力提出了一个问题。这个地方有时真的会觉得不受欢迎。为什么不使用标签呢?我同意Immanish-你为什么要这样做?的确。可以将其样式设置为
display:block
,使其行为类似于块元素(类似于div),因此可以为其指定宽度,高度和其他属性,就像你现在使用div时所做的那样。根本不需要Javascript。如果你使用合适的标记来达到预期目的,你会更喜欢编程。对投票人来说……不要盲目地投票。OP显然是一个初学者,甚至添加了一个代码示例,也努力提出了一个问题。这个地方有时真的会觉得不受欢迎。