jQuery 쓸 때 아이템이 숨겨져 있으면 어떻게 확인하나요?

LONGNEW·2021년 1월 1일
0

StackOverFlaw

목록 보기
8/16

https://stackoverflow.com/questions/178325/how-do-i-check-if-an-element-is-hidden-in-jquery
Q. How do I check if an element is hidden in jQuery?
Q. jQuery 쓸 때 아이템이 숨겨져 있으면 어떻게 확인하나요?
Is it possible to toggle the visibility of an element, using the functions .hide().show(), or .toggle()?
.hide(), .show() 아니면 .toggle() 커맨드로 아이템이 보이도록 껐다가 킬수 있나요??
How would you test if an element is visible or hidden?
어떻게 아이템들이 보이는지 숨겨져 있는지 확인 하나요?


Since the question refers to a single element, this code might be more suitable:
질문이 1개의 아이템에 관한 것이면 아래의 코드가 적절할겁니다.

// Checks CSS content for display:[none|block], ignores visibility:[true|false]
$(element).is(":visible");

// The same works with hidden
$(element).is(":hidden");

It is the same as twernt(다른 유저)'s suggestion, but applied to a single element; and it matches the algorithm recommended in the jQuery FAQ.
twernt의 답변이긴 하지만, jQuery FAQ에서 권장하는 알고리즘에도 맞고, 한개의 아이템에 적절합니다.
We use jQuery's is() to check the selected element with another element, selector or any jQuery object.
우리는 jQuery에서 is() 메소드를 이용해서 선택된 아이템이나, jQuery 객체를 체크합니다.
This method traverses along the DOM elements to find a match, which satisfies the passed parameter.
이 메소드는 넘겨준 파라미터와 DOM 요소들 중에 일치한 것이 있는지 확인합니다.
It will return true if there is a match, otherwise return false.
동일한 것이 있으면 True를 , 없다면 False를 리턴 합니다.

0개의 댓글