Posts

Showing posts with the label HTML

Storing and retrieving data using HTML Local Storage

Here is the sample HTML file with javascript to store data in HTML local storage. You can run it here. Click the below button to add the lines for text1, text2 and text3 in local storage. Add This is text1. Sample text2. Text3 example. If you are using Google Chrome below are the steps to check if the data was stored. Click Menu > More Tools > Developer Tools (Ctrl + Shift + I) Click "Application" In the left pane under Storage navigate to Local Storage > http://SQLGear.blogspot.in In the right pane, you could find the data you just inserted against the key "List".

Get JSON data using Javascript

Below is the code of a simple HTML page used to fetch JSON data. I am using https://jsonplaceholder.typicode.com/ to fetch JSON data from. You can test it here.

Loop through all list items under an ordered or unordered list

Suppose you have the following HTML Code and you want to loop through each <li> tag under the top <ul> or <ol> tag: <ul id=" idOfTheListTag "> <li><ul> <li><input checked="1" type="checkbox" /></li> <li>A1</li> <li>B1</li> <li>C1</li> <li>D1</li> </ul> </li> <li><ul> <li><input checked="1" type="checkbox" /></li> <li>A2</li> <li>B2</li> <li>C2</li> <li>D2</li> </ul> </li> <li><ul id="menu"> <li><input checked="1" type="checkbox" /></li> <li>A3</li> <li>B3</li> <li>C3</li> <li>D3</li> </ul> </li> </ul> To loop through all the <li> tags below is the javascript function:

Make Money from Surveys