4. Moving elements around - please help, I'm lost


#1

I don't understand this one at all.

"move your <p> tag after the <div> with id #one". Didn't I just do exactly that in the excersise before? ("add a <p> tag .after() the <div> with the ID #one")

And how do I "create a new jQuery selector that targets the <div> with the id #two"?
Like this? :

var $selector = $('#two');

How can I use this to move the <p> after #two? I'm sorry, I am completely lost here. The previous excersises were easy, but here I have no idea what am I supposed to do. Please help.


#2

So, what you have to do is add the p tag after the

1 with ID one. To target a specific ID you do this
$('#two').after($('p'));

Hope this helped if it didnt pls reply saying so


#3

It helped, thanks a lot! :smile:


#4

No Problem! Glad to help!!


#5

I was thinking; what if we don't actually know that a paragraph is the element after the first div??I mean, it could be any element. So I used
$('#two').after($('#one').after());
instead so it captures whatever element it is under the first div but that doesn't work. Is there any workaround this??


#6

You could use the class name. So this:$('Class').after($('class').after())

Happy late Merry Christmass :evergreen_tree: :- )


#7

Cant i just do $('div').after($('div')) ?


#8

No you have to select the particular div at first so you have to get it bu the Id Name.And for the particular task you need a p So like this:
$('#two').after($('p'));


#9

What I don't understand is why use two steps of instructions for one line of code? It threw me off. That could have easily been explained in one step. I can understand maybe the level of understanding that should be had at this point, but still.


#10

I just think this task is not clear at all, it's poorly written.


#14

Agreed, these instructions are not clear at all!


#15

it's all in the tag

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


#16

Are you still experiencing that problem?


#17

This was super confusing and I hope they will fix it for future people. Step 1 should have been "Convert your p tag to a variable" and then step two is "now move it after div 2".

They should have explicitly said use a variable.


#19