If jQuery is included in <head> and in <head> if we have some another jQuery code and that code has an id which is a id of an HTML element, so if jQuery library and jquery code in <head> is added globally
And if any page doesn't have that html element which is used by jQuery code then browser gives JavaScript error.
Can I make jQuery/JavaScript code like, if jQuery finds an HTML element with id in <body> then it should work fine.
If another page doesn't have that HTML element with id then I know jQuery will not work.
But what I want:
An error should not be thrown if a page doesn't have an HTML element with the given id.