2
I’m trying to add an HTML code to my HTML via jQuery,Entering any text works,already with a bootstrap tag does not For example:
$(function($){
$('#enviar').click(function (e) {
var linhas = $('#linhas').val();
var plantas = $('#plantas').val();
var combo=$('#haoum').val();
var resultado=Number(linhas)+Number(plantas);
$("#tam").attr("value", resultado);
if ( combo=="ha" ) {
$("#divPrincipal").append("Teste");
}
else
{
}
});
When I run the code a test appears between these tags:
<div id="divPrincipal">
</div>
But when I put it for example:
$(function($){
$('#enviar').click(function (e) {
var linhas = $('#linhas').val();
var plantas = $('#plantas').val();
var combo=$('#haoum').val();
var resultado=Number(linhas)+Number(plantas);
$("#tam").attr("value", resultado);
if ( combo=="ha" ) {
$("#divPrincipal").append("<p class="text-success">Teste</p>");
}
else
{
}
});
It doesn’t work, there is some other function other than 'append'?
Your problem is double quotes inside double quotes. This gives error (check browser console). Use single quotes for outside.
– bfavaretto
Sorry, but how do you open the browser console?
– Rodolfo Oliveira
In Chrome/Windows if I’m not mistaken it’s CTRL+J or F12
– bfavaretto