web api instance property
BatteryManager: charging property
Secure context
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;
});
Interactive exampleOpen the canonical MDN source to run this embedded demo.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.