- function elementSupportsAttribute(element, attribute) {
- var test = document.createElement(element);
- if (attribute in test) {
- return true;
- } else {
- return false;
- }
- };
- 用法示例:
- if (elementSupportsAttribute("textarea", "placeholder") {
- } else {
- // fallback
- }
- //该片段来自于http://www.codesnippet.cn/detail/081120136980.html
来源: http://www.codesnippet.cn/detail/081120136980.html