Analysis and usage of is of ': visible' in jQuery
- 2021-07-21 05:57:08
- OfStack
Instances
Select < body > Each visible element in the element:
$("body :visible")
Definition and usage
The visible selector selects each element that is currently visible.
Elements are visible except for the following situations:
• Set to display: none
• Form elements for type= "hidden"
• Width and height are set to 0
Hide parent element (hide all child elements at the same time)
Grammar
$(":visible")
$(document).ready(function() {
$('#faq').find('dd').hide().end().find('dt').click(function() {//end() To end the previous processing function , Return to the original element
// Explanation : Use end() End find(dd) Adj. hide(), And will find(dt) Act on the original #fap Upper
var answer = $(this).next();//next() Below this element 1 Elements , You can add .next() Indicates down and down 1 Elements , And so on
if (answer.is(':visible')) {// If ANSWER Is visible ,:visible It means visible , Related usages include :hidden( Hide ),:first( No. 1 1 A ),:last( Finally 1 A )
answer.slideUp();// Hide
} else {
answer.slideDown();// Display
}
});
});