As in the event of a tag with data-id="1" to find another tag with data-id="1"?

I have two parent units in a single thread, these blocks are child blocks data-id="".
Interested in how when the hover event to the first parent block with a child block data-id="1", find the child data-id="1" in the second parent unit?
June 3rd 19 at 19:28
1 answer
June 3rd 19 at 19:30
Solution
Exactly as you describe, in the language of the code. Magic functions FindWhatINeed() does not exist.

$('.parent') // get parent units
 .on('mouseenter', '[data-id]', event=>{ // we hang up handlers on the child
 let id = $(event.target).data('id'); // find id
 $(event.target).closest('.parent') // go up to its parent
 .siblings('.parent') // move to the neighbor
 .find('[data-id='+id+']') // get needed child
 //... do something with it do
;
 })


This code will work in both directions.
If you only want one, then make a selection only one parent
$('.parent').eq(0) // take parent units - only the first

Find more questions by tags JavaScriptjQuery