Created
January 21, 2011 13:44
-
-
Save jakejscott/789692 to your computer and use it in GitHub Desktop.
Did you know about the jQuery element constructor ninja?
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
<!doctype> | |
<html> | |
<head></head> | |
<body> | |
<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script> | |
<script> | |
$(document.body).prepend( | |
$('<p>', { | |
id : '123', | |
class : 'wow', | |
text : 'I am a paragraph', | |
title: 'I am a title for this paragraph', | |
'data-thing' : 'some data', | |
click : function(){ | |
console.log('click'); | |
}, | |
mouseleave : function(){ | |
console.log('enter'); | |
$(this).css({ | |
color:'red', | |
background:'#ccc' | |
}); | |
}, | |
mouseenter : function(){ | |
console.log('leave'); | |
$(this).css({ | |
color:'#ccc', | |
background:'red' | |
}); | |
}, | |
css : { | |
color:'red', | |
background:'#ccc', | |
padding : '3px', | |
margin: '10px' | |
} | |
}).click(function(){ | |
console.log('also called') | |
}) | |
); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment