JAVASCRIPT get local storage item javascript - Net-Raft.com

Welcome aboard! We are happy you are here and wish you good net-raft!




Just a Web Code Solution

how to get local storage item using javascript ?


 277

Show ResultJAVASCRIPT


1

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
</head>

<body>

<div id="MyColor">Hello world!</div>

<button id="btn1">red</button></br>
<button id="btn2">blue</button></br>
<button id="btn3">yellow</button></br>
<button id="btn4">save</button>

<script type="text/javascript">

$(document).ready(function () {

var SetColor = localStorage.getItem("font_color");
$("#MyColor").css("color", SetColor);


$("#btn1").click(function () {

$("#MyColor").css("color", "red");

});

$("#btn2").click(function () {

$("#MyColor").css("color", "blue");

});

$("#btn3").click(function () {

$("#MyColor").css("color", "yellow");

});

$("#btn4").click(function () {

var theColorIs = $('#MyColor').css("color");

localStorage.setItem("font_color", theColorIs)

});

});

</script>

</body>
</html>


By        
The power of the user (%)
15%



The most helpful JAVASCRIPT solutions

How to get client machine name or computer name with javascript ?How to get client machine name or computer name with javascript ?JAVASCRIPT

Click to see more ...

  12.4K     391

get client hostname javascriptget client hostname javascriptJAVASCRIPT

Click to see more ...

  4K     274

detect ie javascriptdetect ie javascriptJAVASCRIPT

Click to see more ...

  2.5K     192

Create fireworks using javascriptCreate fireworks using javascriptJAVASCRIPT

Click to see more ...

  2.3K     151

fire event when user is idle javascriptfire event when user is idle javascriptJAVASCRIPT

Click to see more ...

  2K     116

how to create foreach class using javascript ?how to create foreach class using javascript ?JAVASCRIPT

Click to see more ...

  1.7K     112

create 3d barrel using javascriptcreate 3d barrel using javascriptJAVASCRIPT

Click to see more ...

  1.9K     112

create qr code javascriptcreate qr code javascriptJAVASCRIPT

Click to see more ...

  1.3K     103

get ip address javascriptget ip address javascriptJAVASCRIPT

Click to see more ...

  1.2K     78

get filename using javascript get filename using javascript JAVASCRIPT

Click to see more ...

  818     64