var componente = {
HTML :'<div class="alert" style="background-color:#951f2c !important;">' +
'<input type="text" class="form-control titulo-valor" placeholder="Digite o Título do Bloco" style="background-color:#951f2c !important; color: white !important; border:none !important;"/>'+
'</div>'
};
$(document).ready(function(){
$(".btn").on("click",function(){
var componenteAtual = $(this).data("componente");
$(".resultado").html(componente.componenteAtual);
});
});
I'm trying to add elements in html dynamically using JSON with multiple tags inside. It is not working, I gave an alert on componente.componenteAtual
and it is returning undefined
as a result.
If I type componente.HTML
it works ...
Below is the jsfiddle: