2/14


#1

My code:

$(document).ready(function () {
$("Body").append('I\'m a paragraph');
});

Error message:
Oops, try again. It looks like you didn't add a

to the page. Check the Hint if you need help!

Please tell me the correct code thank you


#2

@jgodfroy19,

$(document).ready(function () {
        $("body").append("<p>I'm a paragraph</p>");
});

The Jquery-engine uses the same Selector-syntax as the CSS-engine.

If the HTML-tags like head, body, p, div, a, ul, ol, li, table
are used as a Selector,
then they are written in all-lowercase.
like $('body') or $("body")

In HTML you can add so-called attributes to a HTML-Element
like

  • the class-Attribute like class="active"
    -- to select this HTML-Element you would use $(".active")
  • the id-attribute like id="theOnlyOne"
    --the jQuery-Selector would be $("#theOnlyOne")

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

= = = = = = = = = = = = = = = = = = = = = = = = =

The jQuery-append() Method
= http://api.jquery.com/append/
has several =action-models=
One of those =actions= is adding a complete HTML-Element to the DOM.
like

  <p>I'm a paragraph</p>

The jQuery Statement

 $("body").append("<p>I'm a paragraph</p>");

will add this paragraph-Element as last-Element in the HTML-body.