检测浏览器是否支持某css属性

        var cssProperty = function (attr) {
            var prefix = [ 'O', 'ms', 'Moz', 'Webkit' ],
                len = prefix.length,
                style = document.createElement('i').style;


            if (attr in style) {
                return true;
            }
            attr = attr.replace(/^[a-z]/, function (val) {
                return val.toUpperCase();
            });
            while (len--) {
                if (prefix[ len ] + attr in style) {
                    return true;
                }
            }
            return false;
        };

猜你喜欢

转载自blog.csdn.net/x619y/article/details/77774755