Last active
July 8, 2017 21:04
-
-
Save TheSecretSquad/2b212dd804c580bfff05 to your computer and use it in GitHub Desktop.
Example code from http://benalman.com/news/2010/11/immediately-invoked-function-expression/ written with JQuery and Amber Smalltalk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'a' asJQuery each: [ :index :value | | |
value asJQuery on: 'click' do: [ :event | | |
event preventDefault. | |
window alert: 'I am link #' , index | |
] | |
] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('a').each(function(index, value) { | |
$(value).on("click", function(event) { | |
event.preventDefault(); | |
window.alert("I am link #" + index); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original JavaScript verison: