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

How does jquery determine whether an element is displayed

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to judge whether an element is displayed by jquery". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In jquery, you can use the ": visible" selector and the is () method to determine whether an element is displayed. The syntax is "element object .is (': visible')". You can see if the specified element matches the ": visible" selector, that is, whether it is visible; if the element is displayed, it returns true.

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

In jquery, you can use the ": visible" selector and the is () method to determine whether an element is displayed

The is () method is used to see if the selected element matches the selector.

The visible selector selects each element that is currently visible

Elements are visible except in the following cases:

Set to display:none

Form elements with type= "hidden"

Width and height set to 0

Hidden parent element (this also hides child elements)

Syntax to determine whether an element is displayed:

Element object .is (': visible')

Means to check whether the specified element matches the ": visible" selector, that is, whether it is a visible element

Example:

$(function () {$("button") .click (function () {var node=$ ('span'); if (node.is (': visible')) {alert ("display elements") } else {alert ("hide the element, show it"); node.show ();}}) this is a visible piece of div content. This is a hidden content that is now shown.

This is a visible paragraph.

Determine whether the span element is displayed or not

This is the end of the content of "how jquery determines whether an element is displayed". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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