Reputation: 2828
Heres the code:
$('> li', this).each(function (index) {
var top_space = $(this).css('padding-top');
$(this).prepend('<div></div>');
$('> div', this).css({
position: "absolute",
top: -top_space,
width: "100%",
height: top_space,
"z-index": 0
});
});
Here's the result in inspect element:
As you can see there is no top attribute, but when I remove the negative sign...
There's a top attribute but not working, it's still in top:0
I've been stuck for almost an hour now, can't figure out why. What am I missing?
Upvotes: 2
Views: 70
Reputation: 687
Your top_space will be string so you can't make it like "-top_space"
Try: -(parseInt(top_space))
Upvotes: 1