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

Thursday, November 8, 2012

Codecademy: Sample Solution for "Outside and Inside"



//Sample Solution for script.js
$('document').ready(function() {
$('#changeButton').click(function() {

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

//for the presentation and testing of your result
//(so you shouldn't change!)
$divToInsertBefore.html('Before').addClass('before');
$divToInsertAfter.html('After').addClass('after');

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

//insert $divToInsertBefore to $divToInsertAround
//using .insertBefore()
$divToInsertBefore.insertBefore($divToInsertAround);
//insert $divToInsertAfter to $divToInsertAround
//using .insertAfter()
$divToInsertAfter.insertAfter($divToInsertAround);

});
});

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts