<div id="chargingTime">(charging time unknown)</div>BatteryManager: chargingTime property / notebook
BatteryManager: chargingTime property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
navigator.getBattery().then((battery) => {
const time = battery.chargingTime;
document.querySelector("#chargingTime").textContent =
`Time to fully charge the battery: ${time}s`;
});