Home > Web Front-end > JS Tutorial > body text

jquery's index method implements tab effect_jquery

WBOY
Release: 2016-05-16 18:10:31
Original
983 people have browsed it
jquery's index method implements tab effect_jquery
The tabs are on the left and the details are on the right.

Principle:

Click the list item on the left to display the nth content at [index n] of the list based on the selected list item.

(First, the list and content need to be loaded into the page at one time, and only the first content is displayed, so it is more user-friendly to switch.)

How to get the index of the selected list item in the list:

There is a method in jquery which is index([subject])

$("#ul li").index($("#selected"));

It means first setting the list range (#ul li list), and then returning the index of the $("#selected") element in the list.

After obtaining the index, use $("#detail").hide(); $("#detail").eq(n).show(); to display the details of the same index. (The same goes for option list style switching)

only uses 5 lines.
Related labels:
tab
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!