Created
February 8, 2017 16:44
-
-
Save AntMooreWebDev/bbd29b7f5298409dba12aed9a71ee81b to your computer and use it in GitHub Desktop.
A function to dynamically create a HTML element, with the ability to specify an on-click function.
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 createEl (elType, elId, elClass, onClik, elText) { | |
return $('<' + elType + '>', { | |
id: elId, | |
'class': elClass, | |
text: elText, | |
on: { | |
click: onClik | |
} | |
}); | |
} | |
$('body').append( | |
createEl("div", null, "col-md-6 col-md-offset-3", null, null).append( | |
createEl("div", "mediaArea", null, null, null) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment