To hide a div when the user clicks outside of it, try to run the following codeExampleLive Demo window.onload = function(){ var hideMe = document.getElementById('hideMe'); document.onclick = function(e){ if(e.target.id !== 'hideMe'){ hideMe.style.display = 'none'; } }; }; Click outside this div and hide it.
Double equals (==) is abstract equality comparison operator, which transforms the operands to the same type before making the comparison. For example,4 == 4 // true '4' == 4 //true 4 == '4' // true 0 == false // trueTriple equals (===) are strict equality comparison operator, which returns false for different types and different content.For example,4 === 4 // true 4 === '4' // false var v1 = {'value':'key'}; var v2 = {'value': 'key'}; v1 === v2 //false
C# provides two methods to link value type to reference type and vice e Versa. These two methods for linking are named boxing and unboxing where Boxing is used for the conversion of the value type to an object type while Unboxing refers to the conversion of the object type to the value type.The following are the important differences between Boxing and Unboxing.Sr. No.KeyBoxingUnboxing1ImplementationBoxing made object type referred to as the value type.Unboxing basically processes the retrieving value from the boxed object.2StorageIn the case of boxing, the value stored on the stack is copied to the object stored on heap ... Read More
Along with many other frameworks for front end development AngularJs and Bootstrap are two well-known frameworks in the market.AngularJS is widely used for single page application development as it provides MVC architecture with data model binding. On the other hand, Bootstrap uses HTML, CSS, and JavaScript for its development which makes it comparatively faster.The following are the important differences between Bootstrap and AngularJS.Sr. No.KeyAngularJSBootstrap1Basic DifferenceAngularJs was developed by Google and primarily uses a component concept which makes its developed application more structural.Bootstrap was introduced by Twitter as part of the open-source community with very common libraries such as CSS, Styles, ... Read More
In order to store multiple values or objects of the same type, Java provides two types of data structures namely Array and Collection.The following are the important differences between Arrays and Collection.Sr. No.KeyArraysCollection1SizeArrays are fixed in size i.e once the array with the specific size is declared then we can't alter its size afterward.The collection is dynamic in size i.e based on requirement size could be get altered even after its declaration.2Memory ConsumptionArrays due to fast execution consumes more memory and has better performance.Collections, on the other hand, consume less memory but also have low performance as compared to Arrays.3Data ... Read More
The max attribute of the element is used to set the upper bound for . However, the element is used to measure data with a give range like water impurity level and it is set using the min and max attribute.SyntaxFollowing is the syntax −The num above is a number in floating-point that sets the max attribute of the element.ExampleLet us now see an example to implement the max attribute of the element − Live Demo Water Levels Impurity Level TDS Level OutputThis will produce the following output −In the above example, ... Read More
HTML Forms are required, when you want to collect some data from the site visitor. For example, during user registration you would like to collect information such as name, email address, credit card, etc.A form will take input from the site visitor and then will post it to a back-end application such as CGI, ASP Script or PHP script etc. The back-end application will perform required processing on the passed data based on defined business logic inside the application.The tag is used in HTML to create a form and various form element like input, textarea, etc is included in ... Read More
The element is used in HTML to create hyperlinks along with href attribute. The anchor object represents this element.ExampleIn the below example, we will learn how to access an anchor object − Live Demo Demo Heading Google Display the link Link gets displayed here function display() { var a = document.getElementById("myid").href; document.getElementById("demo").innerHTML = a; } OutputThis will produce the following output −
The HTML DOM Anchor hostname property returns only the hostname of the URL. It returns the domain name.SyntaxFollowing is the syntax to set the hostname property −anchorObj.hostname = hostnameAbove, the hostname is the hostname of the URL.SyntaxFollowing is the syntax to return the hostname property −anchorObj.hostnameExampleLet us now see an example to implement the DOM Anchor hostname property − Live Demo Company Our Team Display Anchor Part Display Host Part Display Hostname function display() { var a = document.getElementById("mylink").hash; document.getElementById("myid").innerHTML = a; } function display2() { ... Read More
The Object.assign() method is used to copy the values of all of the object's own properties(enumerable only) from one or more source objects to a target object. It will return the target object.Exampleconst targetObj = { a: 1, b: 2 }; const sourceObj = { b: 4, c: 5 }; const returnedTarget = Object.assign(targetObj, sourceObj); console.log(targetObj); console.log(returnedTarget); console.log(returnedTarget === targetObj); console.log(sourceObj);Output{ a: 1, b: 4, c: 5 } { a: 1, b: 4, c: 5 } true { b: 4, c: 5 }Note −sourceObj did not change.returnedTarget and targetObj are the same.The Object.assign() method only copies enumerable and own properties from ... Read More