Simple js tab switch effect _ javascript tips-js tutorial

Source: Internet
Author: User
This article mainly introduces how to implement js Tab switching, which has some reference value, if you are interested, you can refer to the examples in this article to introduce the code for implementing the js tab switch effect. The details are as follows:

Ideas:

  • 1. Obtain elements;
  • 2. Add an onclick or onmousemove event to the for loop button element;
  • 3. When you click the current button, it is highlighted. You can set all button styles to null through the for loop calendar and set the display of all p to none.
  • 4. Click the current button to add a style, display the current p, and set display to block.

Html code:

 

11

22

33

44

Css style:

 .active  {  background:#9CC;  } .p2  {  width:300px;  height:200px;  border:1px #666666 solid;  display:none;  }

Js Code:

Script window. onload = function () {var op = document. getElementById ('p1'); // obtain p var btn = op. getElementsByTagName ('input'); // obtain input var p2 = op under p. getElementsByTagName ('P'); // obtain p for (I = 0; I
 
  

The above is all the content of this article, hoping to help you learn.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.