Javascript检测表单元格边框?

Javascript检测表单元格边框?,javascript,html,Javascript,Html,我正在制作一个javascript迷宫游戏,为了在角色碰到墙时停止它,我需要使用if…else语句来检测单元格边界。例如: var blah = document.getElementById('hi').style.border-right; if(blah==20px) { my function } 这可能吗?如果是,那怎么办?谢谢 我不知道,但它将为您提供id=hi元素的右边框样式值我可以理解它的作用,但如何将其添加到代码中?我的例子是在。 function getBorde

我正在制作一个javascript迷宫游戏,为了在角色碰到墙时停止它,我需要使用if…else语句来检测单元格边界。例如:

var blah = document.getElementById('hi').style.border-right;

if(blah==20px) {
    my function
}

这可能吗?如果是,那怎么办?谢谢

我不知道,但它将为您提供id=hi元素的右边框样式值我可以理解它的作用,但如何将其添加到代码中?我的例子是在。
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