Use the jQuery :visible selector to check whether an element is visible in the layout or not.
<!DOCTYPE html> <html lang="en"> <head> <title>jQuery Test If an Element is Visible on a Page</title> <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").toggle("slow", function(){ if($("p").is(":visible")){ document.getElementById("demo").innerHTML = "The paragraph is visible."; } else{//from w w w. j ava 2 s . c om document.getElementById("demo").innerHTML = "The paragraph is hidden."; } }); }); }); </script> </head> <body> <span id="demo"></span> <button type="button">Toggle Paragraph Display</button> <p style="display: none;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eu sem tempor, varius quam at, luctus dui. Mauris magna metus, dapibus nec turpis vel, semper malesuada ante. Vestibulum id metus ac nisl bibendum scelerisque non non purus. Suspendisse varius nibh non aliquet sagittis. In tincidunt orci sit amet elementum vestibulum. Vivamus fermentum in arcu in aliquam. Quisque aliquam porta odio in fringilla. Vivamus nisl leo, blandit at bibendum eu, tristique eget risus. Integer aliquet quam ut elit suscipit, id interdum neque porttitor. Integer faucibus ligula.</p> </body> </html>