您的位置:首页 > Web前端 > HTML

html-判断row中xx属性是否存在及取值

2016-05-24 12:08 387 查看
if (row.getAttribute("custHomePhone") == null || row.attributes["custHomePhone"].value == '')
var custHomePhone = '未填写';
else
var custHomePhone = decodeCellValue(row.attributes["custHomePhone"].value);


getAttribute:使用row的getAttribute方法,判断是否存在“custHomePhone”属性,如果不存在,则赋其他值。

如果不判断,直接取row的value,将会得到下面的错误提示。

VM101:25 Uncaught TypeError: Cannot read property 'value' of undefined
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  html row attribute