//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