JQuery determines whether an element is visible.
This article describes how jQuery judges whether an element is visible. Share it with you for your reference. The details are as follows:
JQuery can easily determine whether an element is visible or hidden, and then perform different processing. For example, I want to display different text and icons on the button based on whether a div is visible. This can be achieved as follows:
Method 1:
$ ('# Para_div button '). click (function () {if ($ (this ). next (). is (": visible") {// ((this).html ('display'); $(this).css ({"background": "url (/images/btn_arrow_down.png) no-repeat "});} else {// response (this).html ('hiding '); Response (this).css ({" background ":" url (/images/btn_arrow_up.png) no-repeat "}) ;}$ (this ). next (). slideToggle ('fast ');});
Method 2:
$ ('# Para_div button '). click (function () {if(((this).next().css ('display') = 'None') {// hide (this).html ('hiding '); then (thisground .css ({"background ": "url (/images/btn_arrow_up.png) no-repeat"});} else {// ((this).html (' '); $(thisground .css ({"background ": "url (/images/btn_arrow_down.png) no-repeat"});} $ (this ). next (). slideToggle ('fast ');});
Method 3:
$ ('# Para_div button '). click (function () {var $ cn = $ (this ). next (); // certificate (this).html ($ cn. is (": visible "))? 'Display': 'hiding '); (this).css ($ cn. is (": visible "))? {"Background": "url (images/btn_arrow_down.png) no-repeat" }:{ "background": "url (images/btn_arrow_up.png) no-repeat"}); $ cn. toggle ('fast ');});
I hope this article will help you with jQuery programming.