I have a question about removing inputs
using js
, for example I have 7 inputs and I want to delete 6 of them leaving only the first, try to use remove()
but this eliminates all of them. thanks in advance.
$(document).ready(function(){
$('#unica-pregunta').change(function(){
var id=$(this).attr("id");
var opciones=id.match(/^([a-zA-Z]+)\-([0-9]+)/g)[0]+'-opcion';
if ($(this).is(':checked')) {
$('#'+opciones).attr('disabled',true).remove().val('');
}else {
$('#'+opciones).attr('disabled',false).show();
}
});
});