Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #176 from ymendel/jquery_v_js_color

make the JavaScript and jQuery examples agree on the color
  • Loading branch information...
commit 2a69b7ab0d85cdcd344bdcf21339945aa224aa13 2 parents be4fc8f + 23d2a6b
Travis Grathwell tjgrathwell authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  sites/frontend/jquery_vs_javascript.step
2  sites/frontend/jquery_vs_javascript.step
View
@@ -13,7 +13,7 @@ steps do
step do
message "Underneath the lines you just commented out, let's take a shot at writing the same functionality in straight JavaScript. There are a number of elegant ways to do this; here's one that's not elegant, but it's short:"
- source_code "js", "document.getElementById('copyright').onclick = function () { \n\s\s this.style.color = 'red';\n}"
+ source_code "js", "document.getElementById('copyright').onclick = function () { \n\s\s this.style.color = 'purple';\n}"
message "If you save the page, refresh, and click, you should see the same visual result (purple text), but this isn't a great approach for a couple of reasons. Not only is this more typing, and harder to read, it's also easily breakable. (You can only set an element's onclick attribute to one thing, so it might get overwritten by another script on the page and not work later!) jQuery works in a different way, by listening for events, so different functions can all be listening for the same event, and you can add a new response to an event without worrying about overwriting an existing one."
end
Please sign in to comment.
Something went wrong with that request. Please try again.