Skip to content

Instantly share code, notes, and snippets.

@jjoseph05
Forked from dbc-challenges/jquery_quiz.js
Last active December 20, 2015 02:09
Show Gist options
  • Save jjoseph05/6054354 to your computer and use it in GitHub Desktop.
Save jjoseph05/6054354 to your computer and use it in GitHub Desktop.
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
/*1. Use basic selectors (id, class, element) to choose an element on the page.
Use the .css() method to alter at least two CSS properties of this element. */
$(".feed-content img").css({"height": "200px" , "width": "200px"});
/*2. Use basic selectors and the find() method to select an image on the page
and change it with another image of your choice. */
$("div .feed-actors").find("img").attr({"src" : "http://upload.wikimedia.org/wikipedia/en/thumb/e/e9/Gandalf600ppx.jpg/220px-Gandalf600ppx.jpg" });
$("div .feed-actors:first").find("img:first").attr({"src" : "http://upload.wikimedia.org/wikipedia/en/thumb/e/e9/Gandalf600ppx.jpg/220px-Gandalf600ppx.jpg" });
/*3. Use traverse methods to select all instances of a repeated word on the page
(like code) and use the animate() method to modify it.
*/
Traversing Dom
Print out all element TagNames
Print out all inner text for each element
** Create jQuery objects in order to use animate() .. a jquery method
Replace the text
.filter()
Reduce the set of matched elements to those that match the selector or pass the function’s test.
$("div#feed > div").filter(":even").css("background-color","green");
$("div#feed > div").filter(function(){
return $(this).text().contains("Design Drill")
});
/* TypeError, but returns text we want ... ?? /*
/*4. Try to find an element that requires at least three selectors / traverse
methods to locate it and then use the .on() method to bind an event handler
on these elements (use an event other than click).*/
/*5. Your choice. */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment