0
Friends, I need to find an element in a tree DOM
a little complex and I’m not getting the result. As I leave the input id = "barcode"
i add new lines below and need to trigger the click on the next reader button.
The code below is with comments that you can understand better.
I am using the following code when exiting the first input
but it’s not working:
var div_leitor = $('div.leitor').nextAll('div.leitor').first();
var barcode_clique = $(div_leitor).find('.barcode_btn');
$(barcode_clique).click();
HTML and comments are in gist as well as js: https://gist.github.com/rvgarimrj/cc8a6cb55364f9859e64785e1e0254bb
Could someone give me a hand ? Thank you
What do you mean "go out" when you write "When exiting input
id = "barcode"
"?– Sergio
The focusout event and I have the above code that doesn’t work. I need to find the next button in the next div and trigger the click event.
– gmadeira
Forehead:
$('#barcode').on('focusout', function(){ $(this).closest('.nested-fields').next().find('.barcode_btn').click();});
– Sergio
I was looking better at that HTML and it seems to me to be wrong... the Divs
<div class="nested-fields">
shouldn’t be siblings? or HTML is actually correct and not at the same DOM level?– Sergio
There is some error in this code. It is not working.
– gmadeira
You saw my HTML question here ^ ?
– Sergio
Sergio, I created a gist with full html and my js for you to understand better. See if you can help: https://gist.github.com/rvgarimrj/cc8a6cb55364f9859e64785e1e0254bb
– gmadeira
Can you put the rendered HTML in gist? the one you put in will be processed right?
– Sergio
Gist updated. This.html output is the result of my already processed Rails application.I’ve pasted the two htmls that will output this.html output.
– gmadeira