Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. MediaList

MediaList

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⁩.

TheMediaList interface represents the media queries of a stylesheet, e.g., those set using a<link> element'smedia attribute.

Note:MediaList is a live list; updating the list using properties or methods listed below will immediately update the behavior of the document.

Instance properties

MediaList.mediaText

Astringifier that returns a string representing theMediaList as text, and also allows you to set a newMediaList.

MediaList.lengthRead only

Returns the number of media queries in theMediaList.

Instance methods

MediaList.appendMedium()

Adds a media query to theMediaList.

MediaList.deleteMedium()

Removes a media query from theMediaList.

MediaList.item()

A getter that returns a string representing a media query as text, given the media query's index value inside theMediaList. This method can also be called using the bracket ([]) syntax.

MediaList.toString()

Returns a string representation of this media list in the same format as the object'sMediaList.mediaText property.

Examples

The following would log to the console a textual representation of theMediaList of the first stylesheet applied to the current document.

js
const stylesheets = document.styleSheets;let stylesheet = stylesheets[0];console.log(stylesheet.media.mediaText);

Specifications

Specification
CSS Object Model (CSSOM)
# the-medialist-interface

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp