Javascript 需要动态更改按钮的位置
也许有人能帮我申请 我有一个正方形和4个按钮(加行、减行、加列、减列)。 我现在需要的是“左减号按钮(行)”-当鼠标位于第二行时,减号按钮应该靠近第二行,如果第一行-靠近第一行,等等 我现在的解决方案如下Javascript 需要动态更改按钮的位置,javascript,html,css,Javascript,Html,Css,也许有人能帮我申请 我有一个正方形和4个按钮(加行、减行、加列、减列)。 我现在需要的是“左减号按钮(行)”-当鼠标位于第二行时,减号按钮应该靠近第二行,如果第一行-靠近第一行,等等 我现在的解决方案如下 功能更改位置(移动){ var top=move.getBoundingClientRect().top; var bottom=move.getBoundingClientRect().bottom; var minusRow=document.getElementById(“delet
功能更改位置(移动){
var top=move.getBoundingClientRect().top;
var bottom=move.getBoundingClientRect().bottom;
var minusRow=document.getElementById(“deleteRow”);
minusRow.style.position=“绝对”;
minusRow.style.top=(top)+“px”;
minusRow.style.bottom=(底部)+“px”;
}
功能更改位置(移动){
var top=move.offsetTop;
var minusRow=document.getElementById(“deleteRow”);
minusRow.style.position=“绝对”;
minusRow.style.top=(top)+“px”;
}
如果生成HTML,则每个div都可以有按钮