Nifty Procrastination Machine

    jquery-debug

    1.0.0 • Public • Published

    jquery-debug

    A plugin that makes jQuery throw an error, rather than fail silently, when a selector returns no results.

    What is this useful for ?

    Save tons of time and frustration debugging jQuery!

    Install

    Install with npm

    npm install --save jquery-debug

    Check out this article for more information on how to use jQuery plugins with npm.

    Usage

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>demo</title>
      <script src="https://code.jquery.com/jquery-3.0.0.js"></script> 
    </head>
    <body>
     
    <div>DIV</div>
     
    <script>
    var element = $('p').debug();
    </script> 
     
    </body>
    </html>

    Here's the error message you would see in the browser console.

    Error: The jQuery selector 'p' was not found in the context of '#document'.
    

    For a live example, check out the CodePen.

    Contributing

    See the CONTRIBUTING Guidelines

    License

    MIT © Jonathan Kemp

    Install

    npm i jquery-debug

    DownloadsWeekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • jonkemp