Before and after - error message


#1

In the before and after lesson I keep getting the following error message:

Oops, try again. It looks like you didn't insert your

after the

with ID #one.

My code is below:

$('#one').after('

Why is it not working

');

What am I doing wrong?

thank you


#2

@webace01351,

Please re-edit your Post

  • leave one blank-line above of your code
  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.

or even better use
= http://discuss.codecademy.com/t/using-backticks-to-format-your-code/3697
[extra's]
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet


#3

thank you for the guidance. I was wondering why it formatted strangely.
Here is the reformatted error message and code. Would be grateful for any insights.

Oops, try again. It looks like you didn't insert your <p> after the <div> with ID #one.

$('#one').after('<p>Why is it not working</p>');

#4

@webace01351,
Did you encapsulate the HTML-code in a document-ready-hull
like

$(document).ready(function(){
   $('#one').after('<p>Any text you like after\'ed</p>');
//   $('#one').before('<p>Any text you like before\'d</p>');
//   $('#one').append('<p>Any text you like appended</p>');
//   $('#one').prepend('<p>Any text you like prepended</p>');
   
});

and

++++ reset of session *****************
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser

and

Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

Addendum
General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).
CTRL 0 to reset browser zoom


#5

Thank you. I hadn't encapsulated it in a document ready function because there was no instruction to do so. Makes sense. Now it works. Thanks again.


#6

@webace01351,

google search
== the Book ==
jquery [your question] site:developer.mozilla.org
CSS [your question] site:developer.mozilla.org
javascript [your question] site:developer.mozilla.org
[your question] site:jquery.com
[your question] site:getbootstrap.com

== discussions / opinions ==
jquery [your question] site:stackoverflow.com
CSS [your question] site:stackoverflow.com
javascript [your question] site:stackoverflow.com

== guidance ==
www.crockford.com
[your question] site:crockford.com
- - http://javascript.crockford.com/code.html
- - http://javascript.crockford.com/survey.html


http://www.w3schools.com/jquery/trysel.asp