MediaQueryListEvent()

The MediaQueryListEvent() constructor creates a new MediaQueryListEvent instance.

Syntax

var myMqlEvent = new MediaQueryListEvent(init);

Parameters

init

An init object that defines features of the new object instance. The available properties are:

  • media: A DOMString representing a serialized media query.
  • matches: A Boolean representing the media query status — true if it matches, false if not.

Examples

var media = '(max-width: 600px)';
var matches = true;

var myMediaQueryListEvent = new MediaQueryListEvent({media, matches});

Specifications

Specification
CSSOM View Module (CSSOM View)
# dom-mediaquerylistevent-mediaquerylistevent

Browser compatibility

BCD tables only load in the browser

See also