Is there a well-known mistake I could be making here?
I've got a script that's using .on() because an element is dynamically generated, and it isn't working. Just to test it out, I replaced the selector with the dynamic element's wrap, which is static, and it still didn't work! When I switched to plain old .click for the wrap it worked, though.
(This just won't work for the dynamic element obviously, the one that matters.)
This works:
$("#test-element").click(function() {
alert("click");
});
This doesn't:
$(document).on("click","#test-element",function() {
alert("click");
});
UPDATE:
I right-clicked and did "Inspect Element" in Chrome to just double-check something, and then after that the click event worked. I refreshed and it didn't work, inspected element, and then it worked. What does this mean?