I’m trying to get a div to appear underneath another div so that I can slide the top div down to reveal the appended second.
I’m pretty far off, but I keep getting an error that jquery’s [offset][1] (which I’d like to use to get the position of the top div) is returning undefined.
Maybe this is just the wrong approach for this. Any help is appreciated.
$(document).ready(function() {
$('.obscure').on('click', function() {
var blueDiv = $('.blue').clone();
// blueDiv.css('display', 'none');
$('#wrapper').append(blueDiv);
var obscure = $('#obscure');
var offset = obscure.offset();
console.log(offset);
/*Uncaught TypeError: Cannot read property 'top' of undefined */
var y = offset.top;
var x = offset.left;
console.log(y);
//blueDiv.css('top', y);
$('.obscure').css('z-index', 10000);
});
});
Do you mean
var obscure = $('#obscure');to readvar obscure = $('.obscure');?