首先先设置一个div,
<div id="box-data" style="width: 120px; height: 50px; background-color: rgba(0,0,0,0.43);position: absolute;display:none;z-index:9999;border-radius:10px;text-align: center;">
</div>
其次,js代码:
$('body').on('mouseover','.voltage-img',function(){
var p = $(this).offset(); #获取当前位置
$("#box-data").show().css({ #控制弹框位置为当前位置
left:p.left-15,
top:p.top+30
}).html("<p>电压值</p><p>"+ value +"</p>");
});