Add Element

by gsguma

HTML

<button id='teste'>Teste</button>

<br />

<div id='lista'></div>

JavaScript

$('#teste').click(function(){
    $('<input>')
        .attr({ type: 'text', name: 'Nome' })
        .css({ backgroundColor: 'red', padding: '5px' }) // Definindo estilos
        .addClass('fundoVermelho')
        .hide()
        .appendTo('#lista') // Adiciona ele ao elemento div com o id myDiv
        .fadeIn(); // Faz o elemento aparecer lentamente
});