Skip to content

Instantly share code, notes, and snippets.

@tsevdos
Created January 2, 2012 10:02
Show Gist options
  • Save tsevdos/1550127 to your computer and use it in GitHub Desktop.
Save tsevdos/1550127 to your computer and use it in GitHub Desktop.
Creating an element in jQuery 1.4
$('<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');
$('<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