I have the following code (coffeescript) and I have rails creating a list of subscription-videos and I want the popup to only popup on the one I hover over. But since since every video in the list has the class subscription-video no matter which I hover over it only shows the popup for the first one. What is the best way to have javascript define that I am looking for the popup id in the currently selected (one I am hovering over) subscription-video class?
$(document).ready ->
$('.subscription-video').hover (->
$('#popup').show()
), ->
$('#popup').hide()
You could do it with DOM traversal. Assuming your subscription-video tag and popup are in the same div:
$(document).ready ->
$('.subscription-video').hover (->
$(this).closest('.popup').show()
), ->
$(this).closest('.popup').hide()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With