I have a .js file that I wrote for my whole sites.  Part of it only
pertain to certain pages, so some of the selectors would not find
anything on other pages.  This file is included in all pages, so my
question is, should I check if a selector exists first, before I run
each script?

I am thinking I could use:

if ( $('#myDiv').length ) {
  // Run my scrip there
}

Reply via email to