Vineeth.mariserla has Published 229 Answers

Insert a node as a child before an existing child in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 09-Aug-2019 10:32:46

Javascript has provided insertBefore() method to insert a node as a child before another child. If there are 2 lists we can shuffle the elements between them based on our requirement using the method insertBefore().syntaxnode.insertBefore(newnode, existingnode);Example-1In the following example, there are two lists and based on our requirement the lists ... Read More

Value of the class attribute node of an element in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 08-Aug-2019 14:37:37

Javascript has provided the getAttributeNode() method to find the attribute node with the specified name of an element, as an attribute object. If the attribute does not exist, the return value is null or an empty string ("").syntaxelement.getAttributeNode(attributename);It returns the attribute object representing the specified attribute node ExampleIn the following example, there are two heading ... Read More

An element inside another element in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 08-Aug-2019 14:00:54

The element inside an element is nothing but for instance a span element inside a div element. Javascript has provided .contains() method to find out whether an element contains another element. This method actually returns true if the condition is satisfied else returns false. syntaxnode.contains(node);ExampleIn the following example, a span element is ... Read More

Number of elements a particular tag contains in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 08-Aug-2019 09:14:43

Javascript has provided childElementCount property to return the number of elements a tag contains in it. The returned value contains only the number but not the values such as the names of the elements etc.syntaxdocument.getElementById("myDIV").childElementCount;It only takes the id name of the tag and returns the number of elements in ... Read More

Built-in javascript constructors?

vineeth.mariserla

vineeth.mariserla

Updated on 07-Aug-2019 13:48:16

Javascript has provided some built-in constructors. Those built-in functions include object(), string(), number, etc. We cannot include Math object in those built-in constructors because Math is a global object. The 'new' keyword cannot be used with Math.ExampleIn the following example, many built-in constructors were used and their types were displayed as shown in ... Read More

How to add a method to a JavaScript object?

vineeth.mariserla

vineeth.mariserla

Updated on 07-Aug-2019 11:00:32

Adding a method to the objectAdding a method to a javascript object is easier than adding a method to an object constructor. We need to assign the method to the existing property to ensure task completion.ExampleIn the following example, initially, the object type is created and later on, the properties ... Read More

Get data from sessionStorage in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 06-Aug-2019 15:40:23

sessionStorageThe localStorage and sessionStorage properties allow to save key/value pairs in a web browser. The sessionStorage object stores data for only one session. The data will be deleted when the browser is closed. It works the same as local storage. Initially, we have to check whether the browser supports the session ... Read More

Weekday as a number in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 05-Aug-2019 14:11:45

WeekdayEvery day in a week, which is from Monday to Sunday, has a number starting from 1 to 7 respectively. Javascript date object has provided the getDay() method to get the day of the week. Let's discuss it in a nutshell.syntaxvar d = getDay();It won't take any parameters and just ... Read More

What is setInterval() method in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 05-Aug-2019 11:53:58

setInterval()This is one of the many timing events. The window object allows code to execute at every certain interval of time. This object has provided SetInterval() to repeat a function for every certain amount of time. It takes two parameters as arguments. One is the function and the other is the time ... Read More

What is setTimeout() Method in javascript?

vineeth.mariserla

vineeth.mariserla

Updated on 05-Aug-2019 11:10:33

 setTimeout()This is one of the many timing events. The window object allows the execution of code at specified time intervals. This object has provided SetTimeout() to execute a function after a certain amount of time. It takes two parameters as arguments. One is the function and the other is the ... Read More

Advertisements