In jQuery, how do I make a selection of an element using "this" within one that I am already selecting

2

I tried to do this:

$(document).ready(function(){

  $("#formulario").submit(function(){

    //Esse trecho não funciona
    $(this "input").each(function(){});

  });

});
    
asked by anonymous 01.10.2017 / 22:50

1 answer

2

You can use $("input", this) or $(this).find("input") .

Example:

$('div').each(function() {
  $("input", this).val('teste'); // seta o value
  $(this).find("input").attr('disabled', false); // tira o disabled
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div><inputtype="text" disabled/>
</div>
    
01.10.2017 / 23:02