Skip to content

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

Notifications You must be signed in to change notification settings

jonkemp/jquery-debug

Repository files navigation

jquery-debug Build Status

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!

Additional information

  • Compatible with jQuery 1.x-2.x. Not compatible with 3.0 yet.
  • Not for use in production (obviously).

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-2.2.4.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.

jquery-debug: 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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published