A plugin that makes jQuery throw an error, rather than fail silently, when a selector returns no results.
Save tons of time and frustration debugging jQuery!
- Compatible with jQuery 1.x-2.x. Not compatible with 3.0 yet.
- Not for use in production (obviously).
Install with npm
npm install --save jquery-debug
Check out this article for more information on how to use jQuery plugins with npm.
<!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.
See the CONTRIBUTING Guidelines
MIT © Jonathan Kemp