0

こんにちは、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>

4

2 に答える 2

3

jquery を使用すると、次のようなことができます。

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

ただし、リンクが必要な場合は、実際に使用する必要があります<a href="...">。そのために作られています。:p

于 2012-08-30T16:05:17.327 に答える
1

答えは、そうではないということです。

html で覚えておくべき重要なルールは、実行したいジョブに正しい要素を使用することです。だからこそ、そのような要素の範囲が存在します。

要素の切り替えをいじり始めると、クロスブラウザーの互換性だけでなく、アクセシビリティに関してワームの缶が開かれます。

HTML アンカー要素を使用します。好きなようにスタイルを設定でき、必要に応じて JavaScript を使用してデフォルトの動作を簡単にオーバーライドできます。Anchor 要素の詳細については、ここに含まれる情報を確認してください。

于 2012-08-30T16:12:32.543 に答える