我正在尝试更改top的内联CSS样式,该样式默认由jQuery使用jQuery CSS((类提供。但它应用了一段时间,然后再次切换到旧的内联CSS顶部样式。
为什么会发生这种情况?
看看jsfiddle。
这就是我所做的:
<script>
`$(".popbutton").on('click',function(e) {
var mousex = e.pageX + 20, //Get X coodrinates
mousey = e.screenY + 20; //Get Y coordinates
var e = jQuery(this);
this.timer=setTimeout(function () {
e.popover("show");
},600);
var menu = $(".popbutton").next(),
menuWidth = menu.width(), //Find width of tooltip
menuHeight = menu.height(), //Find height of tooltip
menuVisY = $(window).height() - mousey, //Distance of element from the bottom of viewport
heightY=$(this)[0].scrollHeight-(1.2*menuHeight);
$(menu).css('top','100px');
});
});`
</script>
因为这个代码:
this.timer = setTimeout(function () {
e.popover("show");
}, 600);
单击按钮时,位置计算正确,但e.popover("显示"(在延迟600ms后再次更改位置。