Created
January 2, 2012 10:02
-
-
Save tsevdos/1550127 to your computer and use it in GitHub Desktop.
Creating an element in jQuery 1.4
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
$('<div/>', { | |
id: 'feature', | |
class: 'post', | |
css: { | |
border : '1px solid red', | |
padding : '5px' | |
}, | |
html: '<p>This is a featured <strong>super</strong> post</p>', | |
click: function() { | |
alert('You click the featured post!') | |
} | |
}).appendTo('body'); |
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
$('<input>', { | |
type: 'text', | |
val: 'text input', | |
css: { | |
border : '1px solid #000', | |
padding : '5px' | |
}, | |
focusin: function() { | |
$(this).val('').addClass("active"); | |
}, | |
focusout: function() { | |
$(this).val('text input').removeClass("active"); | |
} | |
}).appendTo('form'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment