dmotz / oriDomi

🪭 Fold up DOM elements like paper
https://oxism.com/oriDomi
MIT License
2.41k stars 207 forks source link

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

Closed lesliecdubs closed 8 years ago

lesliecdubs commented 8 years ago

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?

dmotz commented 8 years ago

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.)

lesliecdubs commented 8 years ago

Thanks @dmotz! That did the trick.