Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@artlung
Created May 1, 2010 17:20
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save artlung/386498 to your computer and use it in GitHub Desktop.
Save artlung/386498 to your computer and use it in GitHub Desktop.
A simple hello world jQuery example
<html>
<head>
<title>My Sample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var new_num = 40; // global variable
jQuery(document).ready(function(){
http://api.jquery.com/css/
$('p').css({border: '5px solid red', color: 'green', padding: '20px'});
// http://api.jquery.com/bind/
// http://api.jquery.com/css/
// http://api.jquery.com/text/
$('#countme').css({
margin: '0 auto',
backgroundColor: '#ccc',
textAlign: 'center',
fontSize: '40px'
}).bind('click mousemove', function(){
var current = parseInt($(this).text(), 10);
new_num = new_num + 1
$(this).text(current+1).css({fontSize: new_num+'px'})
});
});
</script>
</head>
<body>
<p>Hello</p>
<p>World</p>
<div id="countme">0</div>
<a href="http://api.jquery.com/">Learn more about jQuery's methods</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment