I am creating a div dynamically, then appending it to a container:
var str = '<div class="dimsdiv" id="'+dim.src+'" cursor:pointer;"></div>';
$('#fpdiv').append(str);
Now I need to add a hover even to those divs. I tried to just reference it, but then found that I needed to consider .on() instead. I tried this (before on):
$('#'+dim.src).hover(function{},function{});
But as expected, that didn’t work. I also tried this:
$('#'+dim.src).on('hover','(function{},function{})');
but can’t seem to get the syntax just right. Can someone help here?
Thanks in advance.
You may try this
Also remove the
.fromdim.src, instead usedim_srcasid, it’s used asclassselector in jQuery, not sure why you used it tho but$('#'+dim.src)is invalid.DEMO.