Javascript Archives - Web Development

Category: Javascript

JavaScript array

Using array we can store multiple values in a single javascript variable. The array is a special variable which can store more than one value lets see a small example . Now three variables for three values but if we have 100 car brands then we have to write 100 variables for 100 values.  So…

Read the full article

Javascript inneHTML method

Javascript can display output in four different ways Using innerHTML()Using consol.log()Using document.write()Using window.alert() To access users element we use innerHTML() .The id and class attributes define the HTML elements. document.getElementById(“numberMult”).innerHTML this line will do multiplication & send output <p id=”numberMult”></p> So output will be 129 Now lets see another example of innerHTML You can concatenate…

Read the full article

How to do form validation in javascript

The validation part of javascript is very easy This below code block is doing validation if(name == “”) {printError(“nameError”, “Please enter your name”);} else {var regex = /^[a-zA-Z\s]+$/; if(regex.test(name) === false) {printError(“nameError”, “Please enter a valid name”);} else {printError(“nameError”, “”);nameError = false;}} If you run this code in your broswer         Candidate…

Read the full article

Move object using javascript

imgObj.style.left = ‘0px’; It is used to set object at left side with zero px . imgObj.style.left = ‘100px’; If you set 100px; then it will leave 100px from left side imgObj = document.getElementById(‘img’); imgObj is a variable and storing img id ( id = “img”) function moveRight() { imgObj.style.left = parseInt(imgObj.style.left) + 100 +…

Read the full article