Created
June 10, 2012 23:10
-
-
Save brentsowers1/2907639 to your computer and use it in GitHub Desktop.
jQuery attachment types test case 2
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
function generate10KRandomClass(attachEventDirectly) { | |
var generateFunction = function() { | |
var containerElement = $("#container"); | |
containerElement.html(""); | |
if (!attachEventDirectly) { | |
// There will be 100 possible classes, call .on for each | |
for (var i=0; i < 100; i++) { | |
containerElement.on('click', ".randomClassItem" + i, callbackFunction); | |
} | |
} | |
for (var i=0; i < 10000; i++) { | |
var element = $('<div id="element' + i + '" class="randomClassItem' + Math.floor(Math.random() * 100) + '"><a href="#">click me</a> </div>'); | |
containerElement.append(element); | |
if (attachEventDirectly) { | |
element.click(callbackFunction); | |
} | |
} | |
}; | |
timeAction(this, generateFunction); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment