0
Good evening, I’m trying to add a paragraph when you clicked the button but it’s not working and I can’t figure out why, someone could help?
<script>
$("#btAdd").click(function(){
var texto = document.getElementById("t").value;
$("#new").append("<p>"+texto+"</p>");
});
</script>
and in HTML it looks like this:
<div class="form">
<input type="text" name="text" id="t"/>
<input type="button"
value="Adicionar parágrafo" id="btAdd" /> <br><br>
<input type="button"
value="Aumentar tamanho fonte" id="btAumentarFonte" />
<input type="button"
value="Diminuir tamanho fonte" id="btDiminuirFonte" /><br><br>
<input type="button"
value="Remover último parágrafo" id="btRemoverUltimo" />
<input type="button"
value="Remover todos os parágrafo" id="btRemoverTodos" />
</div>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p>
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p>
<div id="new"></div>
The part of
script
andhtml
are in the same file? Which version of the libraryjQuery
is using?– Rfroes87
@Yes, I am using <script src="jquery-3.5.1.min. js" type="text/javascript"></script> for the jQuery library
– Eduardo Moraes Rigo