2/14. inserting elements


#1

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

why wont this code work? I'm 90% sure it should work


#2

Do you have an element with class .body or you wanted to make $('body').append('I\'m a paragraph');?


#3

I tried the other way and it didn't work


#4

Can you provide full code, and what needs to be done?


#5

these are the instructions:

In the script.js tab, go ahead and .append() a paragraph to the body of your HTML document. Your paragraph should contain the text: "I'm a paragraph!"

my code:
index:

<!DOCTYPE html>
<html>
	<head>
		<title>Result</title>
        <script type='text/javascript' src='script.js'></script>
	</head>
	<body></body>
</html>

js script:

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

error code:

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

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


#6

Instruction:

In the script.js tab, go ahead and .append() a paragraph to the body of your HTML document. Your paragraph should contain the text: "I'm a paragraph!"

your code:

$('body').append('I\'m a paragraph');

so here I\'m a paragraph it's just a text not a paragraph.you have to append a paragraph and Your paragraph should contain this text.

how to create a paragraph in html?


#7

I solved it. Thanks! :grinning:


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.