Reputation: 3296
I am using jQuery to add a new div and position it just after the original div. Everything is working fine and the positioning is right, but when I scroll, the absolute positioned div is acting as fixed
and not scrolling with the content.
Anyone know why this might be?
$('[data-tagging]').after('<div id="tagging-msg"></div>');
$('[data-tagging]').on("keyup", function(e) {
var content = $(this).text();
var go = content.match(start);
var name = content.match(word);
var offset = $(this).offset();
var height = $(this).outerHeight();
var width = $(this).outerWidth();
var top = (offset.top + height) - 3 + "px";
var left = offset.left + "px";
$("#tagging-msg").css({position: 'absolute', top: top, left: left, width: width - 10 + 'px'});
});
Upvotes: 2
Views: 80
Reputation: 4993
You should use quotes between CSS properties name
$("#tagging-msg").css({'position': 'absolute', 'top': top,...
Upvotes: 1