You’re reading the English version of this content since no translation exists yet for this locale. Help us translate this article!
The length
read-only property of the DOMTokenList
interface is an integer
representing the number of objects stored in the object.
بنية الجملة
tokenList.length;
القيمة العائدة
تُعيد رقم صحيح
.
أمثلة
في المثال التالي نقوم بإسترداد قيمة الـ classes الموضوعة داخل <span>
element as a DOMTokenList
using Element.classList
, then write the length of the list to the <span>
's Node.textContent
.
أولاً، الـ HTML:
<span class="a b c"></span>
الآن الـ JavaScript:
var span = document.querySelector("span"); var classes = span.classList; var length = classes.length; span.textContent = 'classList length = ' + length;
نتيجة الكود ستكون بالشكل التالي:
الخصائص
Specification | Status | Comment |
---|---|---|
DOM The definition of 'length' in that specification. |
Living Standard | Initial definition |
دعم المتصفحات
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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
length | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 50 | IE ? | Opera Full support Yes | Safari Full support 5.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 50 | Opera Android Full support Yes | Safari iOS Full support 5.1 | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown