In this lab you will use jQuery methods to answer questions about what's happening on the page, and make changes to elements on the page.
For example, given the following prompt:
problem_set.how_many_h1_tags_are_on_the_page.answer = "YOUR JQUERY GOES HERE";
You would need to select all the h1
tags on the page, and then count them:
// using jQuery (preferred)
$("h1").length;
// or using vanilla javascript
document.querySelector("h1").length;
So your solution would look like this:
problem_set.how_many_h1_tags_are_on_the_page.answer = $("h1").length;
See challenge.js
for the full problem set.
- Clone this repo, and open it in your text editor of choice.
- Launch
index.html
in your Chrome Browser. - Open you Chrome Javascript Console.
- You will see a list of questions, and whether you have answered them correctly.
- We encourage you to primarily code in your console. When you think you've solved a problem, copy your answer into
challenge.js
. And then refresh the page to see if you got it right.
.text()
, .val()
, .attr()
, .addClass()
, .removeClass()
, .show()
, .hide()
, .append()