Skip to content

Instantly share code, notes, and snippets.

@laurenhavertz
Last active December 19, 2015 06:59
Show Gist options
  • Save laurenhavertz/5915419 to your computer and use it in GitHub Desktop.
Save laurenhavertz/5915419 to your computer and use it in GitHub Desktop.
WDI Action Adventure
Task Code
Change the background color of '#target' by script. $('#target').css('background', 'blue');
Change the text in the span, a child of '#target' $('#target span').text('foo:bar');
Create a clone of the span in '#target' and position it under the orgin. $('#target span').clone().insertAfter('#target span');
Change background color of the second of three '.target'. $('.target').eq(1).css('background', 'blue');
Disable the button $('.target button').attr('disabled', 'disabled');
Uncheck the boxes $('.target input').removeAttr('checked');
Move '#child' from '#parent1' to '#parent2' $('#child').appendTo('#parent2');
Make the textbox in '#target' read-only $('#target input').attr('readonly', 'readonly')
Select the second option (of three) in the selectbox by script $('#target select option').eq(1).attr('selected', 'selected')
Remove all children and text of '#target' $('target').empty();
Show Alert with 1 second delay.(Use 'setTimeout') setTimeout(function() {alert('waiting?')}, 1000);
Show the number of children in an alert alert($('#target').find('.child').size());
Make the list-box color alternating.(Make odd options diffrent color) $('#target option').filter(':odd').css('background', 'blue');
Remove all text but h2 $('#target').children().not('h2').remove();

Change the h2 tag to h3 | var target = $('#target'); target.html(target.html().replace(/h2/g,'h3'));

Replace word 'cat' with 'dog' | var target = $('#target'); target.html(target.html().replace(/cat/g,'dog'));

Make '#target' double size with animation | var target=$('#target'); target.animate({ width: target.width() * 2, height: target.height() *2}, 1000);

Make '#target' double size | var target=$('#target'); target.css( { width: target.width() * 2, height: target.height() * 2});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment