Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Rob Harding
Rob Harding
4,128 Points

Why JQuery?

Couldn't all the stuff in this project just be written in html? We could just make a select box manually in html, and use media queries to hide it when its on a small screen.

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Yes, you can, not just this project, technically it's totally possible that you write everything in plain-old HTML/CSS/JavaScript without using any sort of JS libraries.

But, as a developer, when writing a web application, part of your job is to ensure the page look as consistent as possible across all major web browsers. Problem is that there're lots of compatible issues between browsers (particularly older version of IE) , and writing pure JavaScript to manipulate DOM tree is a pain in the neck. That's where jQuery kicks in, it eliminates cross-browser incompatibilities, and makes DOM manipulation trivial.

Other major features of jQuery include, but not limited to, Making it easy to create animation; easy to handle events and Ajax requests; plus tons and tons of plugins.

jQuery is the most popular JavaScript library for one reason -- it's indispensable. Even for web gurus who know everything about browser specs, they still don't wanna write everything in pure JavaScript without using any kinds of library to deal with the browser inconsistency, because doing so will only result in re-writing many functions that have been written in jQuery, so why bother re-inventing the wheels.

Colin Bell
Colin Bell
29,679 Points

Exactly. Work smarter, not harder. There is no reason to rewrite what has already been written (and in jQuery's case, written extremely well).

Bobby Verlaan
Bobby Verlaan
29,538 Points

I think @Rob's question was to make the menu twice in plain old HTML and use CSS to display one or the other. In that way you lose the dependency JavaScript alltogether.

I am not sure why you prefer JavaScript/jQuery, but I think it could be because of SEO reasons as the search bot will see the links only once?

Rob Harding
Rob Harding
4,128 Points

I dont understand. my question was just that all this stuff could be done in html, why would you use javascript

Bobby Verlaan
Bobby Verlaan
29,538 Points

The mobile form solution could be build in HTML/CSS without the use of JS, except for the direction to the right page. I can't think of a solution in HTML/CSS to let the form that uses the GET method open the right page depending on the value of the option. That's where you probably need JS/jQuery?