Discussion on bootstrap Source Code Analysis Tab (tab) _javascript tips

Source: Internet
Author: User

Implementing the Tab tab, this plugin is relatively simple

Source file:

Tab.js

Implementation principle

1. When you click an element, first remove the original highlighted element

2, then to the clicked element to highlight

3, if the click Element is a drop-down box of an option, select itself, and choose the dropdown box

5. If the animation is defined, the animation is performed first and then the callback

SOURCE Analysis:

1. The Show method, which is triggered when you click an element, triggers the following four events

1.1, Hiden.bs.tab: Hide the previous element

1.2, Show.bs.tab: Display the current element

1.3, Hideen.bs.tab: Hide the previous element complete

1.4, Shown.bs.tab: Display the current element complete

1.5, Hiden/show Event source code:

var $previous = $ul. Find ('. Active:last a ')
  var hideevent = $. Event (' Hide.bs.tab ', {
   relatedtarget: $this [0]
  })
  var showevent = $. Event (' Show.bs.tab ', {
   relatedtarget: $previous [0]
})

2. Active: Activating the current object

2.1, add the Aria-expanded property to the navigation element, mark whether this element is in the expanded state

2.2, the use of reflow mechanism, the acquisition of offsetwidth properties to achieve partial redraw

The above article on the bootstrap source code Analysis of the tab (tab) is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.

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.