coffeescript与jquery结合

这两者的结合,可提高开发效率。
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>jQuery meets CoffeeScript</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js"></script>
 
<script type="text/coffeescript">
 
show_message = (msg) ->
$('#message').hide().text(msg).fadeIn(2222,
-> $('#message').append('!')
)
 
$ -> show_message "world"
$('#message').click -> show_message "you"
 
</script>
 
</head>
<body>
<h1>hello <span id="message"></span></h1>
</body>
</html>

你可能感兴趣的:(coffeescrip)