同一个页面中怎样用多次相同的这个js效果?自己试着改了一下,但是不成功~~
<STYLEtype=text/css>BODY{FONT-SIZE:14px;FONT-FAMILY:"宋体"}OLLI{MARGIN:8px}#con{FONT-SI...
<STYLE type=text/css>
BODY {
FONT-SIZE: 14px; FONT-FAMILY: "宋体"
}
OL LI {
MARGIN: 8px
}
#con {
FONT-SIZE: 12px; MARGIN: 0px auto; WIDTH: 373px}
#tags {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 5px; WIDTH: 400px; PADDING-TOP: 0px; HEIGHT: 23px
}
#tags LI {
BACKGROUND: url(images/mainlanmu_01.gif) no-repeat left bottom; FLOAT: left; MARGIN-RIGHT: 1px; LIST-STYLE-TYPE: none; HEIGHT: 21px
}
#tags LI A {
PADDING-RIGHT: 10px; PADDING-LEFT: 10px; BACKGROUND: url(images/mainlanmu_02.gif) no-repeat right bottom; FLOAT: left; PADDING-BOTTOM: 0px; COLOR: #999; LINE-HEIGHT: 21px; PADDING-TOP: 0px; HEIGHT: 21px; TEXT-DECORATION: none;
font-family:"幼圆";
font-weight:bold;
font-size:14px;
}
#tags LI.emptyTag {
BACKGROUND: none transparent scroll repeat 0% 0%; WIDTH: 4px
}
#tags LI.selectTag {
BACKGROUND-POSITION: left top; MARGIN-BOTTOM: -2px; POSITION: relative; HEIGHT: 23px
}
#tags LI.selectTag A {
BACKGROUND-POSITION: right top; COLOR: #1d71e3; LINE-HEIGHT: 23px; HEIGHT: 23px;font-family:"幼圆";
font-weight:bold;
font-size:14px;
}
#tagContent {
BORDER-RIGHT: #aecbd4 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #aecbd4 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: #aecbd4 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #aecbd4 1px solid; BACKGROUND-COLOR: #fff
}
.tagContent {
PADDING-RIGHT: 10px; DISPLAY: none; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; WIDTH: 576px; COLOR: #474747; PADDING-TOP: 10px; HEIGHT: 250px
}
#tagContent DIV.selectTag {
DISPLAY: block
}
</STYLE>
<META content="MSHTML 6.00.2800.1589" name=GENERATOR></HEAD>
<BODY>
<DIV id=con>
<UL id=tags>
<LI><A onClick="selectTag('tagContent1',this)"
href="javascript:void(0)"> 标签一</A> </LI>
<LI class=selectTag><A onClick="selectTag('tagContent2',this)"
href="javascript:void(0)"> 标签二</A> </LI>
<LI><A onClick="selectTag('tagContent3',this)"
href="javascript:void(0)">自适应宽度的标签</A> </LI></UL>
<DIV id=tagContent>
<DIV class=tagContent id=tagContent0>第一个标签的内容</DIV>
<DIV class="tagContent selectTag" id=tagContent1>第二个标签的内容</DIV>
<DIV class=tagContent id=tagContent2>第三个标签的内容</DIV></DIV></DIV>
<p>
<SCRIPT type=text/javascript>
function selectTag(showContent,selfObj){
// 操作标签
var tag = document.getElementById("tags").getElementsByTagName("li");
var taglength = tag.length;
for(i=0; i<taglength; i++){
tag[i].className = "";
}
selfObj.parentNode.className = "selectTag";
// 操作内容
for(i=0; j=document.getElementById("tagContent"+i); i++){
j.style.display = "none";
}
document.getElementById(showContent).style.display = "block";
}
</SCRIPT>
</p>
</BODY>
谢谢两位回答,问题不在延时或者代码位置上,实际用的时候,css、js都是分别在别的文件夹放的,问题在js上,就是需要在同一个页面中使用多个这种js选项卡效果,而且互不干扰~~ 展开
BODY {
FONT-SIZE: 14px; FONT-FAMILY: "宋体"
}
OL LI {
MARGIN: 8px
}
#con {
FONT-SIZE: 12px; MARGIN: 0px auto; WIDTH: 373px}
#tags {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 5px; WIDTH: 400px; PADDING-TOP: 0px; HEIGHT: 23px
}
#tags LI {
BACKGROUND: url(images/mainlanmu_01.gif) no-repeat left bottom; FLOAT: left; MARGIN-RIGHT: 1px; LIST-STYLE-TYPE: none; HEIGHT: 21px
}
#tags LI A {
PADDING-RIGHT: 10px; PADDING-LEFT: 10px; BACKGROUND: url(images/mainlanmu_02.gif) no-repeat right bottom; FLOAT: left; PADDING-BOTTOM: 0px; COLOR: #999; LINE-HEIGHT: 21px; PADDING-TOP: 0px; HEIGHT: 21px; TEXT-DECORATION: none;
font-family:"幼圆";
font-weight:bold;
font-size:14px;
}
#tags LI.emptyTag {
BACKGROUND: none transparent scroll repeat 0% 0%; WIDTH: 4px
}
#tags LI.selectTag {
BACKGROUND-POSITION: left top; MARGIN-BOTTOM: -2px; POSITION: relative; HEIGHT: 23px
}
#tags LI.selectTag A {
BACKGROUND-POSITION: right top; COLOR: #1d71e3; LINE-HEIGHT: 23px; HEIGHT: 23px;font-family:"幼圆";
font-weight:bold;
font-size:14px;
}
#tagContent {
BORDER-RIGHT: #aecbd4 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #aecbd4 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: #aecbd4 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #aecbd4 1px solid; BACKGROUND-COLOR: #fff
}
.tagContent {
PADDING-RIGHT: 10px; DISPLAY: none; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; WIDTH: 576px; COLOR: #474747; PADDING-TOP: 10px; HEIGHT: 250px
}
#tagContent DIV.selectTag {
DISPLAY: block
}
</STYLE>
<META content="MSHTML 6.00.2800.1589" name=GENERATOR></HEAD>
<BODY>
<DIV id=con>
<UL id=tags>
<LI><A onClick="selectTag('tagContent1',this)"
href="javascript:void(0)"> 标签一</A> </LI>
<LI class=selectTag><A onClick="selectTag('tagContent2',this)"
href="javascript:void(0)"> 标签二</A> </LI>
<LI><A onClick="selectTag('tagContent3',this)"
href="javascript:void(0)">自适应宽度的标签</A> </LI></UL>
<DIV id=tagContent>
<DIV class=tagContent id=tagContent0>第一个标签的内容</DIV>
<DIV class="tagContent selectTag" id=tagContent1>第二个标签的内容</DIV>
<DIV class=tagContent id=tagContent2>第三个标签的内容</DIV></DIV></DIV>
<p>
<SCRIPT type=text/javascript>
function selectTag(showContent,selfObj){
// 操作标签
var tag = document.getElementById("tags").getElementsByTagName("li");
var taglength = tag.length;
for(i=0; i<taglength; i++){
tag[i].className = "";
}
selfObj.parentNode.className = "selectTag";
// 操作内容
for(i=0; j=document.getElementById("tagContent"+i); i++){
j.style.display = "none";
}
document.getElementById(showContent).style.display = "block";
}
</SCRIPT>
</p>
</BODY>
谢谢两位回答,问题不在延时或者代码位置上,实际用的时候,css、js都是分别在别的文件夹放的,问题在js上,就是需要在同一个页面中使用多个这种js选项卡效果,而且互不干扰~~ 展开
2个回答
展开全部
<!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" />
<META content="MSHTML 6.00.2800.1589" name="GENERATOR"></HEAD>
<title>无标题文档</title>
<SCRIPT type=text/javascript>
function selectTag(showContent,selfObj){
// 操作标签
var tag = document.getElementById("tags").getElementsByTagName("li");
var taglength = tag.length;
for(i=0; i<taglength; i++){
tag[i].className = "";
}
selfObj.parentNode.className = "selectTag";
// 操作内容
for(i=0; j=document.getElementById("tagContent"+i); i++){
j.style.display = "none";
}
document.getElementById(showContent).style.display = "block";
}
</SCRIPT>
<STYLE type=text/css>
BODY {
FONT-SIZE: 14px; FONT-FAMILY: "宋体"
}
OL LI {
MARGIN: 8px
}
#con {
FONT-SIZE: 12px; MARGIN: 0px auto; WIDTH: 373px}
#tags {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 5px; WIDTH: 400px; PADDING-TOP: 0px; HEIGHT: 23px
}
#tags LI {
BACKGROUND: url(images/mainlanmu_01.gif) no-repeat left bottom; FLOAT: left; MARGIN-RIGHT: 1px; LIST-STYLE-TYPE: none; HEIGHT: 21px
}
#tags LI A {
PADDING-RIGHT: 10px; PADDING-LEFT: 10px; BACKGROUND: url(images/mainlanmu_02.gif) no-repeat right bottom; FLOAT: left; PADDING-BOTTOM: 0px; COLOR: #999; LINE-HEIGHT: 21px; PADDING-TOP: 0px; HEIGHT: 21px; TEXT-DECORATION: none;
font-family:"幼圆";
font-weight:bold;
font-size:14px;
}
#tags LI.emptyTag {
BACKGROUND: none transparent scroll repeat 0% 0%; WIDTH: 4px
}
#tags LI.selectTag {
BACKGROUND-POSITION: left top; MARGIN-BOTTOM: -2px; POSITION: relative; HEIGHT: 23px
}
#tags LI.selectTag A {
BACKGROUND-POSITION: right top; COLOR: #1d71e3; LINE-HEIGHT: 23px; HEIGHT: 23px;font-family:"幼圆";
font-weight:bold;
font-size:14px;
}
#tagContent {
BORDER-RIGHT: #aecbd4 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #aecbd4 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: #aecbd4 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #aecbd4 1px solid; BACKGROUND-COLOR: #fff
}
.tagContent {
PADDING-RIGHT: 10px; DISPLAY: none; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; WIDTH: 576px; COLOR: #474747; PADDING-TOP: 10px; HEIGHT: 250px
}
#tagContent DIV.selectTag {
DISPLAY: block
}
</STYLE>
</head>
<body>
<DIV id="con">
<UL id="tags">
<LI><A onClick="selectTag('tagContent0',this)"
href="javascript:void(0)"> 标签一</A> </LI>
<LI class="selectTag"><A onClick="selectTag('tagContent1',this)"
href="javascript:void(0)"> 标签二</A> </LI>
<LI><A onClick="selectTag('tagContent2',this)"
href="javascript:void(0)">自适应宽度的标签</A> </LI></UL>
<DIV id="tagContent">
<DIV class="tagContent" id="tagContent0">第一个标签的内容</DIV>
<DIV class="tagContent selectTag" id="tagContent1">第二个标签的内容</DIV>
<DIV class="tagContent" id="tagContent2">第三个标签的内容</DIV></DIV></DIV>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<META content="MSHTML 6.00.2800.1589" name="GENERATOR"></HEAD>
<title>无标题文档</title>
<SCRIPT type=text/javascript>
function selectTag(showContent,selfObj){
// 操作标签
var tag = document.getElementById("tags").getElementsByTagName("li");
var taglength = tag.length;
for(i=0; i<taglength; i++){
tag[i].className = "";
}
selfObj.parentNode.className = "selectTag";
// 操作内容
for(i=0; j=document.getElementById("tagContent"+i); i++){
j.style.display = "none";
}
document.getElementById(showContent).style.display = "block";
}
</SCRIPT>
<STYLE type=text/css>
BODY {
FONT-SIZE: 14px; FONT-FAMILY: "宋体"
}
OL LI {
MARGIN: 8px
}
#con {
FONT-SIZE: 12px; MARGIN: 0px auto; WIDTH: 373px}
#tags {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 5px; WIDTH: 400px; PADDING-TOP: 0px; HEIGHT: 23px
}
#tags LI {
BACKGROUND: url(images/mainlanmu_01.gif) no-repeat left bottom; FLOAT: left; MARGIN-RIGHT: 1px; LIST-STYLE-TYPE: none; HEIGHT: 21px
}
#tags LI A {
PADDING-RIGHT: 10px; PADDING-LEFT: 10px; BACKGROUND: url(images/mainlanmu_02.gif) no-repeat right bottom; FLOAT: left; PADDING-BOTTOM: 0px; COLOR: #999; LINE-HEIGHT: 21px; PADDING-TOP: 0px; HEIGHT: 21px; TEXT-DECORATION: none;
font-family:"幼圆";
font-weight:bold;
font-size:14px;
}
#tags LI.emptyTag {
BACKGROUND: none transparent scroll repeat 0% 0%; WIDTH: 4px
}
#tags LI.selectTag {
BACKGROUND-POSITION: left top; MARGIN-BOTTOM: -2px; POSITION: relative; HEIGHT: 23px
}
#tags LI.selectTag A {
BACKGROUND-POSITION: right top; COLOR: #1d71e3; LINE-HEIGHT: 23px; HEIGHT: 23px;font-family:"幼圆";
font-weight:bold;
font-size:14px;
}
#tagContent {
BORDER-RIGHT: #aecbd4 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #aecbd4 1px solid; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: #aecbd4 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #aecbd4 1px solid; BACKGROUND-COLOR: #fff
}
.tagContent {
PADDING-RIGHT: 10px; DISPLAY: none; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; WIDTH: 576px; COLOR: #474747; PADDING-TOP: 10px; HEIGHT: 250px
}
#tagContent DIV.selectTag {
DISPLAY: block
}
</STYLE>
</head>
<body>
<DIV id="con">
<UL id="tags">
<LI><A onClick="selectTag('tagContent0',this)"
href="javascript:void(0)"> 标签一</A> </LI>
<LI class="selectTag"><A onClick="selectTag('tagContent1',this)"
href="javascript:void(0)"> 标签二</A> </LI>
<LI><A onClick="selectTag('tagContent2',this)"
href="javascript:void(0)">自适应宽度的标签</A> </LI></UL>
<DIV id="tagContent">
<DIV class="tagContent" id="tagContent0">第一个标签的内容</DIV>
<DIV class="tagContent selectTag" id="tagContent1">第二个标签的内容</DIV>
<DIV class="tagContent" id="tagContent2">第三个标签的内容</DIV></DIV></DIV>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询