我正在制作一个 JavaScript 迷宫游戏,为了在 Angular 色到达墙壁时停止 Angular 色,我需要使用 if...else
语句来检测单元格边界。例如:
var blah = document.getElementById('hi').style.border-right;
if(blah==20px) {
my function
}
这可能吗?如果是这样,那又如何呢?谢谢!
最佳答案
function getBorders(el)
{
return ["Top", "Right", "Bottom", "Left"].map(
function(v) { return el.style["border"+v+"Width"]; });
}
var b = getBorders(document.getElementById('hi'));
// b is an array with border-width strings (or empty strings)
// in the css order top, right, bottom, left——access with subscripts 0-3
关于Javascript检测表格单元格边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14888371/