visible selector in jQuery with example

Visible selector returns all visible elements, elements that are not hidden.

Example :

<title>visible Selector</title>
<script type="text/javascript" src=""> </script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#myButton").click(function () {
            $("p:visible").css({ 'background-color': 'Orange', 'font-size': '20px' });
<p id="hiddenP">This is paragraph element.</p>
<button id="myButton">Click Me</button>

Demo :

 In the above example, we have used visible selector. Visible selector return all elements that are not hidden. In the above example the visible selector selects the p element and applies CSS to it.


Post a Comment