Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 需要动态更改按钮的位置_Javascript_Html_Css - Fatal编程技术网

Javascript 需要动态更改按钮的位置

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

也许有人能帮我申请

我有一个正方形和4个按钮(加行、减行、加列、减列)。

我现在需要的是“左减号按钮(行)”-当鼠标位于第二行时,减号按钮应该靠近第二行,如果第一行-靠近第一行,等等

我现在的解决方案如下

功能更改位置(移动){
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都可以有按钮