##Finished product image
##Reflection
The structure of this exercise is nearly identical to the javascript DOM manipulation
challenge from DBC unit 3, week 3 (no surprise there). JQuery is so much easier to
grasp from a syntax standpoint: the commands are more concise, and as far as those
that manipulate styles, closer to what you think they'd be if you had to take an
educated guess based on a limited knowledge of jQuery and css. Here's how you'd change
the background color of your <body> tag using javascript:
document.getElementsByTagName('body')[0].style.backgroundColor = "#ccc";And here's the same manipulation using jQuery:
$('body').css({background-color: '#ccc'});See what I mean? So much easier. In jQuery the selector type is implicit, i.e. the second
statement above "knows" that this is a body tag because the word 'body' is written without
any prefix (a "." or "#" for class or id, respectively). But javascript requires you to state
what selection method your using: getElementsByTagName (querySelector will work here as well,
but it's still a lot more to type when compared to the jQuery way.) And then there's the method
(the part that does takes action on your targeted element(s)). When compared to .style.backgroundColor = '#ccc'
the method .css({background-color: '#ccc') is much clearer as to its purpose. We want to manipulate
the element's style and that, of course, is governed by css. And, except for the color requiring quotes
and a missing semi-colon, {background-color: '#ccc'} is exactly how this rule would appear in the css
file.
I discovered that jQuery's .animate() method doesn't accept values that can't be declared in digits.
I attempted to animate the color of the border in this exercise, but since the color can't be expressed
solely in digits, no dice. But you can get this done with css transitions. CSS also has some nifty animations in
its own right. Here are some links if you're interested:
