$(document).ready(function() { // attach a handler to an event for the elements
$("#demo").bind('blur', function(e) {
//dom event fired
});
});
/* As of jQuery 3.0, .bind() has been deprecated.
It was superseded by the .on() method, as presented in the exemple below */
$("#foo").on("click", function(){
alert("User click on foo");
});