Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In my case, I wanted it automatically applied to everything, so I modified the jQuery constructor. I suggest you only use this during development to catch mistakes, but keep it out of your production so as not to confuse others. As it's not an error, I've just used console logging. However I've added a commented out throw in case you would rather use that:</p> <pre><code>var jQueryInit = $.fn.init; $.fn.init = function(arg1, arg2, rootjQuery) { var element = new jQueryInit(arg1, arg2, rootjQuery); if (arg1 &amp;&amp; element.length === 0) { console.log(arg1 +" doesn't exist"); // throw arg1 +" doesn't exist" } return element; }; </code></pre> <p>I really wish there was an option in jQuery for turning this on during dev.</p> <p>In case anybody is wondering... having the selector return a result set, when there are no valid matches, is a deliberate decision by the developers of jQuery. It means you can apply some code to a collection of elements, even if there is a possibility of there being none. A good example is comments on a page, or checked checkboxes. If it threw an error when there were no were elements found, then you would have to add checks for existence to your code. The following topic has more info: <a href="https://stackoverflow.com/a/3709823/109561">https://stackoverflow.com/a/3709823/109561</a></p> <p>This is great feature for keeping production code lean. However it can really bite you in the ass while developing if you make a small typo; or if you try selecting an ID named "foobar" when you should be selecting a class called "foobar".</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload