You can simply add that in the localStorage using .setItem() method of the localStorage and you can retrieve same using .getitem() method. Please find below code to
const btn = document.querySelector(".dark_mode_btn button");
const element = document.querySelectorAll("div, h2, html");
$(btn).click(function(){
if($(element).hasClass('dark_mode'))
{
$(element).removeClass('dark_mode');
localstorage.setItem("darkModeEnabled","true")
} else{
$(element).addClass('dark_mode');
localstorage.setItem("darkModeEnabled","false")
}
});
// To get the Item use localStorage.getItem('darkModeEnabled');
Please make sure to store only string/boolena type data in the storage as it only accepts stringified data.For objects please stringify data using JSON.stringify()
Note : I would suggest to load these values from database instead of storage as you will loose the information once user logout/session-ends or clears the storage.