一个表格内的两个单元格A和B,单元格A内是标题,要求实现点击单元格A内的标题,在单元格B内出现对应的内容,也就是在两个单元格之间实现超链接,请高手指教!

解决方案 »

  1.   

    <html>
    <body>
    <table width="200" border="1">
      <tr>
        <th scope="col"><a  onclick=a()>标题</a></th>
        <th scope="col">标题的内容是:<div id="disp"></div></th>
      </tr>
    </table>
    </body>
    </html>
    <script type="text/javascript">
    function a()
    {
        disp.innerHTML="这里写你要显示的内容";
    }
    </script>
      

  2.   

    方法1:iframe方式
    在单元格B中放置一个iframe,如<iframe src=# scrolling='scroll' name='BCell'>关键是设置iframe的name值,然后将A单元格中超链接的target改为BCell,即iframe的name值
    方法2:js实现
    将A中超链接需要加载的内容全部放到B中,然后把无关的暂时先隐藏起来,当点击超链接后不再是调整,而是执行JavaScript函数,把B中对应的内容显示出来
    方法3:ajax方式
    与方法2差不多,只不过是点击超链接后,执行JavaScript函数,该函数是去重新请求新内容,然后通过innerHTML方法把新内容放到B中
      

  3.   

      用JS做,把B内容用层封装,做点击A把B显示与隐藏
      

  4.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <style>
    </style>
    <script src="jquery-1.3.2.js"></script>
    <script>
    $(document).ready(function(){
        
    $(".test1").children('a').click(function(){
         var id = $(this).parent().attr("id");
     var i= id; 
     $(".test2:eq("+i+")").append("hi");
    });
    });
    </script>
    <script>
    /*d1 = new Date(2009,11,1)
    d2 = new Date(2010,2,31)
    s = []
    days = (Date.parse(d2)-Date.parse(d1))/1000/60/60/24
    for(i = 0;i<=days;i++)
    {
    d =  new Date(2009,11,1+i)
    d = d.getFullYear() + "-" + (d.getMonth()+1) + "-" + d.getDate()
    s.push(d)
    }
    document.write(s.join("<br/>")) */</script>
    </head><body>
    <table width="200" border="1">
      <tr>
        <td class="test1" id="0"><a href="#">1</a></td>
        <td class="test1" id="1"><a href="#">2</a></td>
        <td class="test1" id="2"><a href="#">3</a></td>
      </tr>
      <tr>
        <td class="test2">一</td>
        <td class="test2">二</td>
        <td class="test2">三</td>
      </tr>
      <tr>
        <td class="test3">壹</td>
        <td class="test3">贰</td>
        <td class="test3">叁</td>
      </tr>
    </table></body>
    </html>
    是这个意思吗?我用的是jquery
      

  5.   

    <html>
    <body>
    <table width="200" border="1">
      <tr>
      <th scope="col"><a onclick=a()>标题</a></th>
      <th scope="col">标题的内容是:<div id="disp"></div></th>
      </tr>
    </table>
    </body>
    </html>
    <script type="text/javascript">
    function a()
    {
      disp.innerHTML="这里写你要显示的内容";
    }
    </script>试试啊 
      

  6.   

    一楼和八楼的代码是用onclick的方式来实现的,我本意是想用href来实现,不过还是很感谢大家,包括三楼所提的建议,结贴并向大家表示感谢!