3/14 before and after problem


#1

$(document).ready(function() {
$('#one').after('

hello

')
can anyone tell me what is wrong with this i have looked everywhere and can't find anything

#3

no semicolon after the closing bracket


#4

The lesson asks us to insert a paragraph element immediately following #one, so first we need to create an HTMLString of a P-node inside the after() argument and chain that to the #one selector:

$('#one')  // target the element `<div id="one">Div #1</div>`
.after()   // the after() method
'<p>Hello!</p>'   // an HTMLString of a P-node

Putting this all together, we get,

$('#one').after('<p>Hello!</p>');

Be sure there are no line breaks in your quoted string. Keep everything, including quotes, on the same line.


#5

Hi! I think I have put the right code but it still gives me an error.

$('#one').after('<p>Hi</p>');

Can anyone see the problem here? I have also tried with document ready at the beginning


#7

It's important to use the ready() method to defer our code until after the page HTML has loaded. Until then, #one and #two don't exist yet.

$(document).ready(function(){
    $('#one').after('<p>My paragraph inserted after #one</p>');
});

#12