Posted By

omerta83 on 07/08/10


Tagged

javascript jquery


Versions (?)

How to check some element for existing


 / Published in: JavaScript
 

  1. /*The .length property in jQuery returns the length
  2. or number of elements inside an array or the string
  3. length. If you want to check the existence of the
  4. element, just check if the returned value of length
  5. is zero:*/
  6.  
  7. if ($(selector).length)
  8. {
  9. //your code here
  10. }
  11.  

Report this snippet  

You need to login to post a comment.