Debugging jQuery — a practical guide to debugging jQuery with clear examples you can reuse in real projects.
jQuery Tutorial Series (95/101). Prefer one article? Read the complete jQuery tutorial.
Short description
If length is 0, your selector or ready timing is wrong.
Debug tip
console.log($('#btn').length);
console.log($('#btn').get(0));
// Breakpoint in DevTools Sources on your handler