Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of getting ID by Jquery selector through class name

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "the method of Jquery selector getting ID through class name". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "Jquery selector gets ID through class name" can help you solve the problem.

Obtained by class name

Press class to find and note that add a.: before the class name:

Vara=$ ('.red'); / / all nodes containing `class= "red" `will be returned.

/ / for example:

/ /...

/ /...

Find objects that contain multiple class names, such as "car" and "bus"

Vara=$ ('.car.bus'); / / Note there are no spaces!

/ / nodes that meet the criteria:

/ /...

/ /...

Get the ID of p through its class name

Sometimes we only know that p's class name contains one of its names, and we want to get its id.

$(".tab-pane.active") .attr ("id")

/ / results that meet the criteria:

One

/ /...

Get the class of p through its ID name

$(".tab-pane.active") .attr ("id")

$("p#hrefMenu0") .attr ("class")

/ / results that meet the criteria:

Tab-panebusactive

/ /...

Get the ID of the subset node under p through the class name of p

$(".tab-pane.active") .children () .attr ("id") / / get the following two id:content,page

Obtain the ID of the peer node under p through the class name of p

$(".tab-pane.active") .next () .attr ("id") / / get the following id:content

This is the end of the introduction to "how the Jquery selector gets the ID through the class name". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report