I've seen a few different solutions but I can't seem to make them work. The solution I attempted is based on this question:jQuery hover not working with dynamic elements. I'm not seeing a distinguishable difference between the answer provided for that question and my own.
Here's the link for the jsfiddle that they used also: http://jsfiddle.net/qgTzE/4/
Dynamically created element:
<div class="deckCardListCard floatRight ui-corner-all" data-cardID="190563" id="1">190563</div>
Javascript to add hover:
$(".deckCardListCard").on({
mouseenter: function() {
$("#deckCardDisplay").css("background-image", "url('images/cards/" + $(this).attr("data-cardID") + ".png')");
},
mouseleave: function() {
$("#deckCardDisplay").css("background-image", "url('images/layout/back.png')");
}
});
** EDIT **
I have selected an answer from below but the question is more why what I have doesn't work when the apparent same thing works here: jQuery hover not working with dynamic elements