Moving Elements Around


#1

can someone explain to me this code i do not feel it is right ? Is what i'm doing correct or there is something that I'm missing here here is my code below

$(document).ready(function(){
var $paragraph = $("

I'm adding text after div 1

");
$("#two").after($paragraph);

});


#2

It looks like you forgot to put paragraph tags around your text.


#3

you should insert it between

...

tags

#4
var $paragraph = $('<p>Yes!</p>');

$(document).ready(function() {
    $('#one').after($paragraph);
    $('#two').after($paragraph);
});

#5

Hi,

I completed this section but it was more fluke than anything else. I think I did not understand the first instruction:

1. In script.js, add a new line below your code to move your < p > tag after the < div > with id #one

My solution does not feel right even though I was able to pass to the next section.
This is how I did it:

> $(document).ready(function() {
>     //$('#one').after('<p>You can place any text you like in p tags</p>')
>     var $p = $('<p>You can place any text you like in p tags</p>')
>     $('#two').after($p);

> });

Can you tell me why it feels off to me?


#6

It's still a bit strange anyway. I also passed this lesson by adding <p> pair </p>, but wait... In HTML we can place just text (without any tags) to <body>, so why don't lazy jQuery wish to add some text without tags after div tag? Any ideas?


#7

This is what I used:

$(document).ready(function() {
$('#one').after($paragraph)
var $paragraph = $('<p>Wassup</p>')
$('#two').after($paragraph);
});


#8

Cheers bro. Really helped show where I was going wrong.


#9