W3cubDocs

/Web APIs

BatteryManager: charging property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The charging read-only property of the BatteryManager interface is a Boolean value indicating whether or not the device's battery is currently being charged. When its value changes, the chargingchange event is fired.

If the battery is charging or the user agent is unable to report the battery status information, this value is true. Otherwise, it is false.

Value

A boolean.

Examples

>

HTML

<div id="charging">(charging state unknown)</div>

JavaScript

navigator.getBattery().then((battery) => {
  const charging = battery.charging;

  document.querySelector("#charging").textContent = charging;
});

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
charging 38 79 43–52 25 No 38 43–52 25 No 3.0 38 No

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager/charging