Skip to content

Instantly share code, notes, and snippets.

@brentsowers1
Created June 10, 2012 23:12
Show Gist options
  • Save brentsowers1/2907648 to your computer and use it in GitHub Desktop.
Save brentsowers1/2907648 to your computer and use it in GitHub Desktop.
jQuery attachment types test cases 3 and 4
function generateUniqueClasses(attachEventDirectly, elementsToGenerate) {
var generateFunction = function() {
var containerElement = $("#container");
containerElement.html("");
for (var i=0; i < elementsToGenerate; i++) {
var element = $('<div id="element' + i + '" class="differentClassItem' + i + '"><a href="#">click me</a> &nbsp;</div>');
containerElement.append(element);
if (attachEventDirectly) {
element.click(callbackFunction);
} else {
containerElement.on('click', ".differentClassItem" + i, callbackFunction);
}
}
};
timeAction(this, generateFunction);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment