Check an Element is Exists in JQuery

Then We Use .Length property to check an element is exists and if the element is exists then return total number of match element.

  1.  <head id="Head1" runat="server">  
  2. <title></title>  
  3. <script src="JS/jquery-1.3.2.min.js" type="text/javascript"></script>  
  4. <script type="text/javascript">  
  5.     $(document).ready(function () {  
  6.         $("#btnGet").click(function () {  
  7.             if ($('#DivB').length)  
  8.             { alert("DivA exists"); }  
  9.             else {  
  10.                 alert("DivB does not exists");  
  11.             }  
  12.         });  
  13.     });  
  14. </script>  
  15. </head>  
  16. <body>  
  17. <form id="form1" runat="server">  
  18. <div style="padding-left: 100px">  
  19. <br />  
  20. <div id="DivA">  
  21. </div>  
  22. <asp:Button ID="btnGet" runat="server" Text="Check If Exists" OnClick="btnGet_Click" />  
  23. </div>  
  24. </form>  
  25. </body>  
Output

check if existes

DivB Not Exixts then:

dibB