2
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 dynamically add html elements using JSON with multiple tags inside. It’s not working, I gave an Alert on componente.componenteAtual
and he’s returning undefined
as a result.
If I write componente.HTML
works...
Below is the jsfiddle: