What's wrong with this code?


#1

$(document).ready(function(){
var $paragraph = $("p");
$("#one").after($paragraph);
$("#two").after($paragraph);
});

pls help me...what is wrong with the code?
I couldn't find the "post a question section", sorry for asking here.


4. Moving elements around
#2

Hi Srivani,

Please post

  1. A link to the exercise you're on
  2. The error message you're getting

Thanks!


#3

You don't need $ at var paragraph = $('p');, you just use keyword var, you use $ in PHP for variables.
So your code should look like this

$(document).ready(function() {
  var paragraph = $("p");
  $("#one").after(paragraph);
  $("#two").after(paragraph);
});

#5

why does the site show an assignment of:
var $paragraph = $("p");
when it causes an error after we run it??


#6

If I run the exact code you have posted I get:

Oops, try again. It looks like you didn't add a p after the

with ID #two.

#7

Can you post your exact code? I was just referring to the OP's code and explained him how to make a variable (with var, not $).