Javascript检测表格单元格边框?

标签 javascript html

我正在制作一个 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/

相关文章:

javascript - 如何从搜索中排除包含转义字符的整个单词?

javascript - 从动态元素中检索数据时,jQuery.data() 返回 'undefined'

html - 相对于父级对齐 HTML 特殊字符底部

javascript - 通过对象过滤 MultiCheckbox

javascript - jQuery 自动完成渲染项目未执行

html - 防止长单元格内容拉伸(stretch)单元格

html - 在编辑模式下向内容编辑器 Web 部件添加更宽的图像使其重叠

javascript - 响应式 vuejs 数组不使用 v-for 显示其内容

javascript - 如何更改 ES6 箭头函数的 'this' 指向的内容?

css - 使用 HTML5 为现代浏览器嵌入 Flash 的最佳方式?