Quotes help make search much faster. Example: "Practice Makes Perfect"

Thursday, November 8, 2012

Codecademy: Sample Solution to "Appending and Prepending Too"


//Sample solution for script.js


$('document').ready(function() {
$('#changeButton').click(function() {

//use $('<div/>') to create two new divs
var $divToAppend = $('<div />');
var $divToPrepend = $('<div />');

//for the presentation and testing of your result
//(so you shouldn't change!)
$divToAppend.html('Append').addClass('appended');
$divToPrepend.html('Prepend').addClass('prepended');

var $divToInsertInside = $('#insertHere');

//append $divToAppend to $divToInsertInside
//using .appendTo
$divToAppend.appendTo($divToInsertInside);

//prepend $divToPrepend to $divToInsertInside
//using .prependTo
$divToPrepend.prependTo($divToInsertInside);

});
});

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts