Created
May 30, 2012 02:38
-
-
Save s-hiroshi/2833178 to your computer and use it in GitHub Desktop.
JavaScript > pattern > argument to callback function
This file contains hidden or 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
<div id="hoge"> | |
<p>Foo</p> | |
<p>Bar</p> | |
</div> | |
<div><button id="botton">Click</button></div> |
This file contains hidden or 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
var paragraph = $('#hoge p'); | |
$('#botton').click(function() { | |
var i; | |
for (i = 0; i < paragraph.length; i++) { | |
$(paragraph[i]).animate({ | |
'font-size': 30 | |
}, function(j) { | |
return function() { | |
$(paragraph[j]).text(j +': ' + $(paragraph[j]).text()); | |
} | |
}(i)); | |
} | |
}); |
This file contains hidden or 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
#hoge { | |
margin: 10px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment