Common usage of the is () function in jQuery
Checks the Matching Element Set Based on the selector, DOM element, or jQuery object. If at least one element matches the given expression, true is returned.
If no element matches, or the expression is invalid, 'false' is returned '. '''Note: ''' only supports all expressions in jQuery 1.3. In previous versions, if a complex expression is provided, such as a hierarchical selector (for example, + ,~ And>), always returns true
Instance:
$ (Document ). ready (function () {$ ('# faq '). find ('dd '). hide (). end (). find ('dt '). click (function () {// end () is the end of the previous processing function, return to the initial element // explanation: end the hide () of find (dd) with end (), and apply find (dt) to the first # fap var answer =$ (this ). next (); // next () can be added to the next element of this element. next () indicates the next element, and so on if (answer. is (': visable') {// If ANSWER is visible, visible indicates visible, and its usage also includes: hidden (hidden),: first (first ),: last (last) answer. slideUp (); // hide} else {answer. slideDown (); // display }});});
Answer. is (': visable') refers to the visible answer element.
If it is visible, call answer. slideUp (); to hide it.
Else is an invisible element. Call answer. slideDown (); to display it.
Similar works include answer. is (': first') answer. is (': last') and so on, similarCssA: hover