This is a table of JavaScript snippets that I have written. Now, many of these snippets may exist on other pages by coincidence because most of these pieces of code are extremely basic. Also, those who want to be serious about web development should not overly rely on code snippets. Doing so could turn you into a script kiddie. Nevertheless, these code snippets may help those new to code. Furthermore, those who are not interested in web development could copy and paste these pieces of code.
As a side note, some of these snippets might also work on Node.js.HTML | CSS | JavaScript | Description |
N/A | N/A |
function compositeHTMLElement(tag) { var container = document.createElement(tag); for(var i = 1; i < arguments.length; i++) { container.appendChild(arguments[i]); } return container; } |
compositeHTMLElement creates an HTML element that contains other HTML elements that are specified in the arbitrary arguments. That is, it creates a composite HTML element made up of other HTML elements specified by the other arguments. Then, it returns the new super-element.
These subelements have an HTML element with the specified HTML tag as their parent.
Here is the syntax for the function call:
compositeHTMLElement(string HTMLTagName, node subelement...)
|