Div making jquery impossible to locate next element

0

Friends, I have the following question:

The following code below finds the next element from the clicked select: link

It works perfectly.

The problem is that by including the child formatting divs between fields, it can not find the next element anymore, showing them as undefined, see code:

link

What was the mistake I made?

    
asked by anonymous 24.09.2016 / 15:45

2 answers

0

From what I noticed in your code, in the second example link <select> is not within <div class=".caixa-dependentes2"> so when you try to call the function:

$('.caixa-dependentes2').on('change', '.aa', function(){
var proximo = $(this).nextAll('.bb').eq(0).val();
alert(proximo);
});

It does not work because <div> is empty

    
24.09.2016 / 19:54
0

Try using the following:

var proximo = $(this).parents('.caixa-dependentes2').find('.bb').eq(0).val();
    
25.09.2016 / 13:34