Writing tab effects with JS

Writing tab effects with JS

This article example shares the specific code for JS to write tab effects for your reference. The specific content is as follows

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{
            padding:0;
            margin:0;
        }
        .selectka {
            width:500px;
            height:400px;
            margin:auto;
            border:1px solid #09e1ff;
        }
        .left,.right{
            float:left;
            height:400px;
        }
        #menu{
            text-align: center;
            line-height: 80px;
            font-size: 20px;
            color:purple;
        }
        li{
            list-style: none;
        }
        #menu>li{
            width:100px;
            height:80px;
            border:1px dashed blueviolet;
            box-sizing: border-box;
        }
        .right{
            position: relative;
            width:399px;
            background: pink;
            margin-left:1px;
            text-align: center;
            font-size: 100px;
            line-height: 400px;

        }

        .right li{
            position: absolute;
            width:399px;
            height:400px;
            display: none;
        }
    </style>
</head>
<body>
<div class="selectka">
    <div class="left">
        <ul id="menu">
            <li class="menulist">Clothes</li>
            <li class="menulist">Beauty</li>
            <li class="menulist">Bags</li>
            <li class="menulist">Food</li>
            <li class="menulist">Jewelry</li>
        </ul>
    </div>
    <div class="right">
        <ul>
            <li class="numlist">Clothes</li>
            <li class="numlist">Beauty</li>
            <li class="numlist">Bag</li>
            <li class="numlist">Food</li>
            <li class="numlist">Jewelry</li>
        </ul>
    </div>
</div>
<script>
    var menu_list = document.getElementsByClassName("menulist");
    var num_list = document.getElementsByClassName("numlist");
    var moo = null;
    var yuu=null;
        for(var i=0;i<menu_list.length;i++) {
            menu_list[i].index = i;
            menu_list[i].onmouseenter = function () {
                /* console.log(this.index);*/ //this.index is the index value of the current target/* for(var k=0;k<num_list.length;k++){
                    num_list[k].style.display = "none";
                }
                num_list[this.index].style.display = "block";
            }*/
                if(yuu)yuu.style.background = "none";
                this.style.background = "yellow";
                yuu=this;
                 if(moo)moo.style.display="none";
                num_list[this.index].style.display = "block";
                moo = num_list[this.index];
        }
}
</script>
</body>
</html>

Effect picture:

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • js to implement simple tab function
  • js to achieve a simple switchable tab effect
  • js tab implementation method
  • JavaScript realizes the tab switching effect (self-written native js)
  • Detailed explanation of JS implementation of tab example
  • js to achieve Tab tab switching effect
  • Implementing simple tabs with js
  • Two ways to write JS tab plugins (jQuery and class)
  • js uses iframe to achieve tab effect
  • js to realize simple tab production

<<:  Detailed explanation of several ways to install CMake on Ubuntu

>>:  Linux uses lsof/extundelete tools to restore accidentally deleted files or directories

Recommend

Why the explain command may modify MySQL data

If someone asked you whether running EXPLAIN on a...

Question about custom attributes of html tags

In previous development, we used the default attr...

Detailed process of using nginx to build a webdav file server in Ubuntu

Install nginx Note that you must install nginx-fu...

A useful mobile scrolling plugin BetterScroll

Table of contents Make scrolling smoother BetterS...

Semantics, writing, and best practices of link A

The semantics, writing style, and best practices ...

How to view the creation time of files in Linux

1. Introduction Whether the creation time of a fi...

Detailed process of using Vscode combined with docker for development

Preface Using Docker and VS Code can optimize the...

How to handle forgotten passwords in Windows Server 2008 R2

What to do if you forget Windows Server 2008R2 So...

mysql code to implement sequence function

MySQL implements sequence function 1. Create a se...

Detailed explanation of nodejs built-in modules

Table of contents Overview 1. Path module 2. Unti...

How to implement Mysql scheduled task backup data under Linux

Preface Backup is the basis of disaster recovery....

Example of using CSS3 to create Pikachu animated wallpaper

text OK, next it’s time to show the renderings. O...

Some functions of using tcpdump to capture packets in the Linux command line

tcpdump is a flexible and powerful packet capture...

Vue implements small notepad function

This article example shares the specific code of ...