Good when I want to add an html to the page using jQuery
I do this:
$("body").html('ddd');
But in this way I delete the old content, can I add the html in the Body without deleting the content of the page?
Good when I want to add an html to the page using jQuery
I do this:
$("body").html('ddd');
But in this way I delete the old content, can I add the html in the Body without deleting the content of the page?
What you're looking for is append , add within the element after all:
$("body").append('ddd');
Or prepend that adds inside the element but first of all:
$("body").prepend('ddd');
Example:
$("body").append('<p>Eu vou para depois do conteudo do body</p>');
$("body").prepend('<p>Eu vou para antes do conteudo do body</p>');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h2>Eu vou estar no meio depois dos outros serem inseridos</h2>
Yes, using append :
$(seletor).append();
You can use jQuery's append method
$( "body" ).append( "Seu texto" );