Front End Technology Articles

Page 630 of 652

In how many ways can we find a substring inside a string in javascript?

vineeth.mariserla
vineeth.mariserla
Updated on 30-Jul-2019 160 Views

We can find a substring inside a string in two ways. One way is using the indexOf() method and the other is using ES6 includes() method. let's discuss them in detail.indexOf()syntaxindexOf(str);This method tries to check the index of the substring we need. If there is index, which means substring is present, then true will be displayed in the output else false will be displayed as output. This method is case sensitive. ExampleLive Demo var company = "Tutorix"; document.write(company.indexOf('Tutor') !== -1); document.write(""); document.write(company.indexOf('tutor') !== -1); Outputtrue falseincludes()syntaxincludes(str);Unlike the indexOf() ...

Read More

What is the importance of _.union() method in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 30-Jul-2019 1K+ Views

_.union()_.Union() method belongs to underscore.js a library of javascript. The _.union() function is used to take n number of arrays and return a new array with the unique terms in all those arrays (union of all array). It scrutinizes each and every value of the arrays and pushes out unique values into another array.syntax_.union( array1, array2, .... );ExampleIn the following example, _.union() is used to get an array of unique elements.Live Demo document.write(_.union([1, 2, 9, 40], ...

Read More

How to get the application name and version information of a browser in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 30-Jul-2019 2K+ Views

Javascript has provided a navigator object with which we can find any information regarding the browser. To get the application name and version information, navigator object has provided navigator.appName() and navigator.appVersion() respectively. Let's discuss each of them individually.Application Name of the browserTo get the application name, the navigator object has provided navigator.appName(). It may sound weird that "Netscape" is the application name for IE11, Chrome, Firefox, and Safari. So the output we get when we use navigator.appName() is Netscape.ExampleLive Demo document.write(navigator.appName); OutputNetscapeBrowser version informationTo get the browser version information, the navigator object has provided ...

Read More

HTML DOM Input Number form Property

Sharon Christine
Sharon Christine
Updated on 30-Jul-2019 147 Views

The HTML DOM input number form property returns the reference of the form that contains the number input field in the HTML document.SyntaxFollowing is the syntax −object.formExampleLet us see an example of HTML DOM input number form property − Live Demo body{ text-align:center; background-color:#1b203a; color:#fff; } form{ margin:2.5rem auto; border:1px solid #fff; padding:2rem; ...

Read More

How to get the pixel depth and color depth of a screen in JavaScript?

vineeth.mariserla
vineeth.mariserla
Updated on 30-Jul-2019 593 Views

Javascript window object has provided many methods to get various kinds of information regarding the browser.  It has provided screen.colorDepth and screen.pixelDepth to get the color depth and pixel depth of browser screen respectively. Let's discuss them individually.Color depthThe window object has provided screen.colorDepth method to return the color depth. Color depth is nothing but the number of bits used to display one color. All modern computers use 24 bit or 32 bit hardware for color resolution.ExampleLive Demo document.getElementById("depth").innerHTML = "Screen color depth is " + screen.colorDepth; OutputScreen color depth ...

Read More

HTML DOM Input Date form Property

Kumar Varma
Kumar Varma
Updated on 30-Jul-2019 152 Views

The Input Date form property returns the reference of enclosing form for input date.SyntaxFollowing is the syntax −Returning reference to the form objectinputDateObject.formExampleLet us see an example of Input Date form property − Live Demo Input Date Form Date Select: Get Form ID    function getFormID() {       var inputDate = document.getElementById("Date");       var divDisplay = document.getElementById("divDisplay");       divDisplay.textContent = 'Form ID for date input: '+inputDate.form.id;    } OutputThis will produce the following output −Before clicking ‘Get Form ID’ button −After checking ‘Get Form ID’ button −

Read More

HTML DOM Input Date stepDown() Method

AmitDiwan
AmitDiwan
Updated on 30-Jul-2019 120 Views

The HTML DOM Input Date stepdown() method defines the amount of days the date field should decrease.SyntaxFollowing is the syntax −Calling stepDown method with a number, which by default is equal to 1inputDateObject.stepDown(number)ExampleLet us see an example of Input Date stepDown method − Live Demo Input Date stepDown() Calendar: Decrease by 2 Decrease by 3    var divDisplay = document.getElementById("divDisplay");    var inputDate = document.getElementById("dateSelect");    function changeStep(num){       if(num===2)          inputDate.stepDown(2);       else          inputDate.stepDown(3);       divDisplay.textContent = 'Current date decreased by: '+num;    } OutputThis will produce the following output −Clicking ‘Decrease by 2’ button −Clicking ‘Decrease by 3’ button −

Read More

HTML DOM paddingLeft Property

Sharon Christine
Sharon Christine
Updated on 30-Jul-2019 158 Views

The HTML DOM paddingLeft property returns and add left padding to an HTML element.SyntaxFollowing is the syntax −1. Returning left paddingobject.style.paddingLeft2. Adding left paddingobject.style.paddingLeft=”value”ValuesHere, “value” can be the following −ValueDetailslengthIt defines value padding in length unit.initialIt defines padding to its default value.inheritIn this padding gets inherited from its parent element.percentage(%)It defines padding in percentage of the width of parent element.ExampleLet us see an example of paddingLeft property − Live Demo HTML DOM paddingLeft property    .outer-box{       background-color:#db133a;       width:300px;       height:300px;       margin:1rem auto;    }   ...

Read More

HTML DOM Input Date stepUp() Method

AmitDiwan
AmitDiwan
Updated on 30-Jul-2019 114 Views

The HTML DOM Input Date stepUp() method defines the amount of days the date field should increase.SyntaxFollowing is the syntax −Calling stepUp method with a number, which by default is equal to 1inputDateObject.stepUp(number)ExampleLet us see an example of Input Date stepUp method − Live Demo Input Date stepUp() Calendar: Increase by 2 Increase by 3    var divDisplay = document.getElementById("divDisplay");    var inputDate = document.getElementById("dateSelect");    function changeStep(num){       if(num===2)          inputDate.stepUp(2);       else          inputDate.stepUp(3);       divDisplay.textContent = 'Current date increased by: '+num;    } OutputThis will produce the following output −Clicking ‘Increase by 2’ button −Clicking ‘Increase by 3’ button −

Read More

HTML DOM Input Button name Property

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 172 Views

The HTML DOM name property returns and alter the value of name attribute of an input button in HTML.SyntaxFollowing is the syntax −1. Returning nameobject.name2. Modifying nameobject.name=”text”Here, “text” represents the new name of the input button.ExampleLet us see an example of name property − Live Demo HTML DOM name Property    body{       text-align:center;    }    .btn{       display:block;       margin:1rem auto;       background-color:#db133a;       color:#fff;       border:1px solid #db133a;       padding:0.5rem;       border-radius:50px;       width:80%;    }   ...

Read More
Showing 6291–6300 of 6,517 articles
« Prev 1 628 629 630 631 632 652 Next »
Advertisements