SyntaxFix
Write A Post
Hire A Developer
Questions
You have to append it. Create the element with:
var $div = $("<div>my div</div>"); $div.click(function(){alert("clicked")}) return $div;
Then if you append it will work.
Take a look at your example here and a simple version here.