รหัสการสลับแท็บแท็บที่สามารถใช้กับ JS (JavaScript) สามารถปรับให้เข้ากับความกว้างโดยอัตโนมัติและคุณสามารถเพิ่มและลบบล็อกแท็กด้วยตัวเอง
การคัดลอกรหัสมีดังนี้:
<! doctype html public "-// w3c // dtd html 4.01 transitional // en" "http://www.w3c.org/tr/1999/rec-html401-
19991224/loose.dtd ">
<html xmlns = "http://www.w3.org/1999/xhtml"> <head>
<meta name = "คำหลัก" content = "รหัส js, แท็บแท็บ, รหัสโฆษณา js, รหัสเอฟเฟกต์พิเศษ JS, Yuewei Caotang" />
<title> การนำทางแท็กสำหรับความกว้างปรับตัว </title>
<meta http-equiv = content-type content = "text/html; charset = gb2312">>
<style type = text/css>
Body {Font-Size: 14px;
ol li {margin: 8px}
#CON {FONT-SIZE: 12PX;
#tags {Padding-Right: 0px;
ด้านบน: 0px;
#tags li {พื้นหลัง: URL (images/tagleft.gif) ไม่มีการทำซ้ำด้านล่างซ้าย;
ไม่มี;
#tags li a {padding-right: 10px;
Float: left;
ไม่มี}
#tags li.emptytag {พื้นหลัง: ไม่มีการเลื่อนโปร่งใสซ้ำ 0% 0%;
#TAGS LI.SELECTTAG {ตำแหน่งพื้นหลัง: ด้านซ้ายสุด;
#TAGS LI.SELECTTAG A {ตำแหน่งพื้นหลัง: ด้านบนขวา;
#TAGCONTENT {Padding-Right: 1px;
1px;
.TAGCONTENT {Padding-Right: 10px;
Padding-bottom: 10px;
#tagcontent div.selectat {display: block}
</style>
<meta content = "mshtml 6.00.2800.1589" ชื่อ = เครื่องกำเนิด> </head>
<body>
<div id = con>
<ul id = แท็ก>
<li class = selectTag> <a onMouseOver = "selectTag ('tagcontent0', this)" href = "JavaScript: void (0)"> แท็ก 1 </a> </li>
<li> <a onMouseOver = "selectTag ('tagcontent1', this)" href = "JavaScript: void (0)"> แท็ก 2 </a> </li>
<li> <a onMouseOver = "selectTag ('tagcontent2', this)" href = "JavaScript: void (0)"> แท็กที่มีความกว้างปรับตัว </a> </li>
<li> <a onMouseOver = "selectTag ('tagcontent3', this)" href = "JavaScript: void (0)"> ความกว้างแบบปรับตัว </a> </li>
</ul>
<div id = tagcontent>
<div class = tagcontent id = tagcontent0> เนื้อหาของแท็กแรก </div>
<div id = tagcontent1> เนื้อหาของแท็กที่สอง </div>
<div class = tagcontent id = tagcontent2> เนื้อหาของแท็กที่สาม </div>
<div class = tagcontent id = tagcontent3> เนื้อหาของแท็กที่สี่ </div>
</div>
</div>
<script type = text/javascript>
ฟังก์ชั่น selecttag (showcontent, selfobj) {
// แท็กการทำงาน
var tag = document.getElementById ("แท็ก"). getElementsByTagname ("li");
var taglength = tag.length;
สำหรับ (i = 0; i <taglength; i ++) {
tag [i] .className = "";
-
selfobj.parentNode.className = "selectTag";
// เนื้อหาการทำงาน
สำหรับ (i = 0; j = document.getElementById ("tagcontent"+i); i ++) {
J.Style.Display = "ไม่มี";
-
document.getElementById (showcontent) .style.display = "block";
-
</script>
</body> </html>