dmotz / oriDomi

🪭 Fold up DOM elements like paper

Home Page:http://oridomi.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Targeting multiple elements, or individual elements within .each()

lesliecdubs opened this issue · comments

Hi there! Great plugin.

I have several elements on the page using the same class that, on hover, I would like to apply an oriDomi effect to. I currently have the hover event set up inside a .each() that loops through all of the elements with the class in question.

Unfortunately, it seems that oriDomi only targets the first DOM element that matches the selector provided. Is there a way to target a specific element via the selector (i.e., $(this).find('.my-element')), or to target all elements of a specific class name?

If you're already using an each loop, try something like this:

$('.some-class').each(function() { 
  var $this = $(this).oriDomi()
  $this.hover(function() {
    $this.oriDomi('accordion', 50)
  })
})

(Replacing the effect call with the one you want.)

Thanks @dmotz! That did the trick.