How to get or set value of div id in localstorage?

i have this div to set font bold
this is before to click

<div id="bold_item" value="0" class="text_item bar_options_item">
		<i class="icon_bar fa fa-bold"></i>

now after clicked on (B)
will be like that

<div id="bold_item" value="1" class="text_item bar_options_item sel_item">
		<i class="icon_bar fa fa-bold"></i>

My question is how to save value=“1” and sel_item class to get that after reload the page … i mean after click on b button and reload the page …The B BUTTON must still active after reload the page… i need to do that by localstorage

Button on click sessionStorage.setItem(‘itemName’, value).

Document ready const savedValue = sessionStorage.getItem(‘itemName’)

Basically that’s it with some added null checks but that’s the pseudo code basics.

can you give me demo ?

This just sounds like “Can you do all the work for me”.

Why not attempt it yourself and let us know if you get stuck.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.