javascript - Cannot find element based on attribute -


i trying raise mouseenter event element, when hovering on element. trying find element based on data attribute:

 $("#modal").on("mouseenter", ".jq_pin", function(e) {         var attr = $(this).data("abbr");         var els = $(".jq_mappoint");         var el = els.find("[data-abbr='" + attr  + "']");         el.trigger(e.type);     }); 

my event fires, , debugging can see list of elements jq_mappoint class, , 1 has matching data attribute, length of el 0.

element event:

<li class="jq_pin"data-abbr="n">hi</li> 

element im trying target:

<div style="position:absolute;left:59%;bottom:72%" class="jq_mappoint" data-abbr="n">n</div> 

you need .filter() instead of .find()

reduce set of matched elements match selector or pass function's test.

var el = els.filter("[data-abbr='" + attr  + "']"); 

instead of

var el = els.find("[data-abbr='" + attr  + "']"); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

r - Update two sets of radiobuttons reactively - shiny -