Home Web Front-end JS Tutorial Production of jquery tab page_jquery

Production of jquery tab page_jquery

May 16, 2016 pm 06:27 PM
jquery tab Bookmark page

One thing you need to pay special attention to here is to set a delay for the mouseover event of the label, so as to prevent the user from maliciously moving the mouse, causing a large number of requests and causing the server to crash. The setTimeout function is used, mainly for the downloaded events

1 $().each(function(){}) This is a very important way to traverse all tags

2 mouseover event,

and the key css style Write and control the displayed style,

Copy code The code is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>tab </TITLE>
< link rel="stylesheet" type="text/css" href="css/tab.css">
<script type="text/javascript" src="js/jquery-1.4.2.js" ></script>
<script type="text/javascript" src="js/tab.js"></script>
</HEAD>

<BODY>
<ul id="ularea">
<li class="listli">Tag1</li>
<li >Tag2</li> < ;/div> 🎜>



Copy code


The code is as follows:

ul ,li { margin:0px;
padding: 0px; height:20px;
color:white;

}
.listli { background-color: #663333;
border:1px solid #663333;

}
div { clear:left;
width:300px;
height:100px;
background-color: #663333;
border-top:0px;
color:white;
display:none;
}

.divarea { display:block; }


The next step is to write js to control sliding




Copy the code


The code is as follows:

// Define global variables
var timeout;
$(document).ready(function(){ //Find all li tags $("li").each(function(index){ $(this).mouseover(function(){ //Sliding doors must set a delay time to prevent users from moving the mouse wildly and causing the server to crash. This is very importanttimeout =setTimeout (function(){
$("div.divarea").removeClass("divarea");
$("li.listli").removeClass("listli");
// $( "div").eq(index).addClass("divarea"); //Another way to write it is:$(div:eq(index)).addClass("divarea");
$("div: eq(" index ")").addClass("divarea");
$("li").eq(index).addClass("listli");
},
320);
$(this).mouseout(function(){
clearTimeout(timeout);
});
});
});
});

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of jQuery reference methods: Quick start guide Detailed explanation of jQuery reference methods: Quick start guide Feb 27, 2024 pm 06:45 PM

Detailed explanation of jQuery reference methods: Quick start guide

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery?

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Use jQuery to modify the text content of all a tags

Understand the role and application scenarios of eq in jQuery Understand the role and application scenarios of eq in jQuery Feb 28, 2024 pm 01:15 PM

Understand the role and application scenarios of eq in jQuery

How to tell if a jQuery element has a specific attribute? How to tell if a jQuery element has a specific attribute? Feb 29, 2024 am 09:03 AM

How to tell if a jQuery element has a specific attribute?

Summary of commonly used file operation functions in PHP Summary of commonly used file operation functions in PHP Apr 03, 2024 pm 02:52 PM

Summary of commonly used file operation functions in PHP

See all articles