DOMTokenList:toString() 方法
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
DOMTokenList
接口的 toString()
字符串化器方法将标记(token)列表的值序列化为字符串返回。返回值是以空格分隔的标记列表,与 DOMTokenList.value
属性值相等。
语法
js
toString()
参数
无。
返回值
一个字符串。
示例
js
const element = document.createElement("div");
const classes = element.classList;
element.className = "shop empty-cart";
classes.add("logged-in", "dark-mode");
console.log(classes.toString());
// "shop empty-cart logged-in dark-mode"
规范
Specification |
---|
DOM # DOMTokenList-stringification-behavior |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
toString |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.