Skip to content

Instantly share code, notes, and snippets.

@sjl
Forked from ryancrum/jquerytest.cljs
Created July 21, 2011 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjl/1097260 to your computer and use it in GitHub Desktop.
Save sjl/1097260 to your computer and use it in GitHub Desktop.
How to use jQuery from ClojureScript
(ns jquerytest.core)
(def jquery (js* "$"))
; Can you not use the short form?
(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>
@ryancrum
Copy link

Ah, you can indeed. Even better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment