Warsaw, Poland
tomandquery@gmail.com

JS

Iterate over object and array
4.08.2018

Iterate over object and array

var obj = { name: “Tom”, age: “30”, hobbies: { photography: “nature”, isHappy: true }, array: [1, ‘one’, true] } for (var property in obj) { if (obj.hasOwnProperty(property)) { console.log(obj[property]); } } Object.keys(obj).forEach(function(key, index, value)...
Read more

Save form state, serialize, cookie, local storage – working

<style> body { width: 100%; height: 100%; background-color: grey; } </style> <body> <form action="self" method="post"> <div> <label for="name">Name:</label> <input type="text" id="name" name="user_name"> </div> <div> <label for="mail">E-mail:</label> <input type="email" id="mail" name="user_mail"> </div> <div> <label for="msg">Message:</label> <textarea...
Read more

Javascript snippets

document.getElementById("p2").style.color = "blue"; document.getElementById("p2").style.fontFamily = "Arial"; document.getElementById("p2").style.fontSize = "larger"; var element = document.getElementById("div1"); element.classList.add("otherclass"); element.classList.remove("otherclass"); var x = document.getElementsByClassName("example"); x[0].innerHTML = "Hello World!";
Read more
1 2 3 4