Skip to content

Instantly share code, notes, and snippets.

@ryancrum
Created July 21, 2011 02:24
Show Gist options
  • Save ryancrum/1096382 to your computer and use it in GitHub Desktop.
Save ryancrum/1096382 to your computer and use it in GitHub Desktop.
How to use jQuery from ClojureScript
(ns jquerytest.core)
(def jquery (js* "$"))
(jquery
(fn []
(-> (jquery "div.meat")
(.html "This is a test.")
(.append "<div>Look here!</div>"))))
<html>
<head>
<script type="text/javascript" src="out/goog/base.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="jquerytest.js"></script>
<script type="text/javascript">
goog.require("jquerytest.core");
</script>
</head>
<body>
<div class="meat">Replace me, jquery.</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment