I am attempting to utilize jQuery in order to detect the position of a div with the class name of .field_slide-produit. My goal is to use this position information to place another div (.slider-content) directly below it on the bottom left, and I also need this new div to be dynamically adjusted when the window is resized.
After implementing the following code, I realized that it is not functioning as expected. Can anyone provide insight into why this might be?
var offset = $('.field_slide-produit').offset();
var height = $('.field_slide-produit').height();
var width = $('.field_slide-produit').width();
var top = offset.top + height + "px";
var right = offset.left + width + "px";
$('.slider-content').css( {
'position': 'absolute',
'right': right,
'top': top
});
// Listen for window changes and adjust the position of the newdiv
$(window).resize(function(){ slider-content(); });
You can view this code in action on Codepen here: http://codepen.io/Laurentfrom47/pen/wJEKVb
Thank you!