一个表格内的两个单元格A和B,单元格A内是标题,要求实现点击单元格A内的标题,在单元格B内出现对应的内容,也就是在两个单元格之间实现超链接,请高手指教!
解决方案 »
- 调用google map怎么不能得到SubAdministrativeArea等的信息
- FF中json解析的诡异的问题,
- 怎样让火狐支持这段代码?
- 事件冒泡问题。急!!在线等。
- 怎样实现自动选择单选框并自动选择删除选项?
- 这是getFullYear()的bug吗?
- 原来程序也有亲家关系,来看来JAVA的远房亲戚JAVASCRIPT
- 我在A.htm页面打开B.htm 然后从B.htm返回值给A.htm的listbox控件 用opener怎么不行
- 求助!如何动态显示中文日期?
- 请问:怎么设定输入模式?信誉第一,肯定给分!
- jQuery jBox的一个小问题 请达人帮助解决下 我折腾好长时间没弄明白了
- js读取xml文件,赋值给selec控件
<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>
在单元格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中
<!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
<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>试试啊