I am trying to modify the attributes of an input that I generate dynamically and that I show on the page through ajax.
function traigo_form(){
$.ajax({
data:{enviado: true}
type: "POST",
url: "localhost/miproyecto/traer_form.php",
success: function(data){
$('#formulario').html(data);
}
});
$("#valor").attr("type","hidden");
}
<button onclick="traigo_form()" id="boton" value="traer"></button>
<div id='formulario'>
</div>
<?php
if($_POST['enviado']){
$formulario="<form>
<input id=\"nombre\" type=\"text\">
<input type=\"text\" id=\"valor\">
</form>";
echo $formulario;
}