4/14 heeeelllppppp


#1
$(document).ready(function() {
$('#one').after('<p>hnhnoi</p>')
$('<p>').after('#two')

});


#2

Your code is correct up to line 3. What we need to do is first select '#two' and then insert the earlier created paragraph node which we also need to select:

$('#two').after($('p'));

Note that we are using a P-node selector to target that paragraph. Being the only one in the document for the present, it will move <p>hnhnoi</p> to just following <div id="two">Div #2</div>

Div #1
Div #2
hnhnoi

A little difference to note, here:

$('p')

selects all P-nodes in the document. (P-node is my way of saying paragraph element nodes.)

$('<p>')

creates a P-node, but does not insert it into the DOM until we order it.

var $newPara = $('<p>').text('Hello!');
$newPara.appendTo('body');

The page will now display,

Hello!

and if we inspect the element, it will look like this,

<p>Hello!</p>

and we will see that its parent element is <body></body>.


#4

Please can someone tell me why I have message

"Oops, try again. It looks like you added more than one <p> ! ?

My code.

$(document).ready(function() {
$('#one').after('<p> test </p>');
$('#two').after($('p'));
});

#5

Hello,

I just tried executing your code and it did execute successfully. Refresh your page and try executing again. Hope it helps


#6

Thank You !
I don't know why but i tried this before and finally now thats works.


#7

thank you baby royyyyyyyyyyyyyyyyyyy


#9