dom / latest / batterymanager / charging.html /

BatteryManager.charging

The BatteryManager.charging property 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, this value is true. Otherwise, it is false.

Value

A boolean.

Examples

HTML Content

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

JavaScript Content

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

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

Specifications

Browser compatibility

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

See also

© 2005–2021 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