Created
August 2, 2010 19:43
-
-
Save elijahmanor/505193 to your computer and use it in GitHub Desktop.
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
//Quick Element Contruction Syntax | |
//Instead of concatenating strings together to build up new HTML elements, | |
//you can now utilize a new feature inside of jQuery 1.4 for quick element construction. | |
//You can pass a map of properties as the second parameter to set attributes and wire-up event handlers | |
//Keep in mind certain elements cannot be created this way due to limitations in some browsers (Internet | |
//Explorer for example). Elements you will have trouble with include `input` and `button` elements. | |
$("<a />", { | |
id: "companyLink", | |
text: "appendTo", | |
title: "The jQuery Company", | |
href: "http://appendTo.com", | |
rel: "external", | |
click: function() { alert("Rocks!"); return false; } | |
}).appendTo('body'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment