Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ex1 #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions exercises/js/sandbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//Select all of the div elements that have a class of "module".
$('div.module')

//Come up with three selectors that you could use to get the third item in the #myList unordered list. Which is the best to use? Why?
$('#myList>li:nth-child(3)');
$('#myList>li:eq(2)'); // is this same as next?
$('#myList>li').eq(2); //This one is better because nth-child will not work if structure is changed. Also mylist>li will work only if li is direct child.
$('#myList li').eq(2);


//Select the label for the search input using an attribute selector.
$("label[for='q']");

//Figure out how many elements on the page are hidden
$(":hidden").length;

//Figure out how many image elements on the page have an alt attribute.
$("img[alt]").length;

//Select all of the odd table rows in the table body.
('tbody>tr:odd');