Skip to content

Instantly share code, notes, and snippets.

@daneharrigan
Created July 2, 2014 22:24
Show Gist options
  • Save daneharrigan/b7e2e8731a63d6a68ddc to your computer and use it in GitHub Desktop.
Save daneharrigan/b7e2e8731a63d6a68ddc to your computer and use it in GitHub Desktop.
// this will only affect the input fields that exist in the html prior to this code running.
// if your application.js file exists in the <head> tag all of your input fields come after
// this code runs so it doesn't see any input fields
$("input").on("focus", function(){
console.log("at=first event=focus")
});
// similar to at=first but uses $(document) instead of $("input")
$(document).on("focus", "input", function(){
console.log("at=second event=focus")
})
$(function(){
// same as at=first but wrapped by $(function(){ ... })
$("input").on("focus", function(){
console.log("at=third event=focus")
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment