How do I access elements inside a dynamic element with jquery

1

Good afternoon.

I have a question. I use the command load (do jquery) to load a page, and inside it has a form. When this form is processed, it should change the div that is in the same load hierarchy.

I'm trying to do this:

$("#conteudo").on('form[name=formCadastraQuadra]').submit(function(){

   //como eu acesso os elements inputs deste cara?

});

Thank you very much

    
asked by anonymous 23.03.2016 / 20:34

1 answer

1

When you use a delegated event, the this within the callback is the element to which the event was delegated. So the this will be the form and to get the downstream inputs of this form you can use .find() . Something like this:

$("#conteudo").on('submit', 'form[name=formCadastraQuadra]', function(){
    $(this).find('input').each(function(i, el){
        // aqui o "el" e o 'this' corresponde ao elemento iterado
    
23.03.2016 / 20:58