Skip to content

Instantly share code, notes, and snippets.

@conman246
Forked from dbc-challenges/jquery_quiz.js
Last active December 25, 2015 12:39
Show Gist options
  • Save conman246/6977598 to your computer and use it in GitHub Desktop.
Save conman246/6977598 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. */
$(".span8").css("color","red");
/*2. Use basic selectors and the find() method to select an image on the page
and change it with another image of your choice. */
("img[alt='Luis Perez']").attr("src", "http://jdcarpediem.files.wordpress.com/2012/01/mighty_ducks.gif");
/* this changes the image with alt attribute 'Luis Perez', by changing the src to "http:jd......"
/*3. Use traverse methods to select all instances of a repeated element on the page
(like the h3 surrounding the words 'Code Review' ) and use the animate() method to modify it.
*/
$('.user').children('a').last().animate({fontSize:'150px'});
/*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).*/
$('.user').children('a').eq(2).on("hover", function() { alert( $(this).text('you suck!') ); });
/* this jquery uses $(this).text to refer to the link we are targeting, and replacing it with the text, 'you suck!', and gives an empty alert message */
$('.user').children('a').eq(2).on("hover", function() { alert('alex says, you suck!') ; });
/* this jquery on hover gives an alert that says 'you suck!'*/
/*5. Your choice. */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment