Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Front End Technology Articles
Page 589 of 652
How to add a number of months to a date using JavaScript?
To add a number of months to a date, first get the month using getMonth() method and add a number of months.ExampleYou can try to run the following code to add a number of monthsLive Demo var d, e; d = new Date(); document.write(d); e = d.getMonth()+1; document.write("Incremented month = "+e);
Read MoreHow to determine if an argument is sent to the JavaScript function?
To determine if an argument is sent to function, use “default” parameters.ExampleYou can try to run the following to implement itLive Demo function display(arg1 = 'Tutorials', arg2 = 'Learning') { document.write(arg1 + ' ' +arg2+""); } display('Tutorials', 'Learning'); display('Tutorials'); display();
Read MoreHow to use variable number of arguments to function in JavaScript?
To use a variable number of arguments to function, use the arguments object.ExampleYou can try to run the following code to implement arguments to a function in JavaScriptLive Demo function functionArgument(val1, val2, val3) { var res = ""; res += "Expected Arguments: " + functionArgument.length; res += ""; res += "Current Arguments : " + arguments.length; res += ""; res += "Each argument = " for (p = 0; p < arguments.length; p++) { res += ""; res += functionArgument.arguments[p]; res += " "; } document.write(res); } functionArgument(20, 50, 80, "Demo Text!","Hello World", new Date())
Read MoreWhat is the JavaScript version of sleep()?
The JavaScript version of sleep() is “await”. The await feature pauses the current aync function.ExampleYou can try to run the following code to implement sleep in JavaScriptLive Demo function setSleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } async function Display() { document.write('Wait for 5 seconds!'); await setSleep(5000); document.write('After 5 seconds!'); } Display();
Read MoreHow to define functions inside a function body in JavaScript?
To achieve what you want, use JavaScript Closures. A closure is a function, which uses the scope in which it was declared when invoked. It is not the scope in which it was invoked.ExampleLet’s take your example and this is how you can achieve your task. Here, innerDisplay() is a JavaScript closure.Var myFunction = (function () { function display() { // 5 }; function innerDisplay (a) { if (/* some condition */ ) { // 1 // 2 display(); }else { // 3 // 4 display(); } } return innerDisplay; })();
Read MoreWhere are JavaScript variables stored?
Like many other programming languages, JavaScript has variables. Variables can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container.JavaScript variables get stored in the memory of the browser process. The following ways can work for storing variables:The variables which you declare in your JavaScript code gets saved in the memory of the browser process.Cookies can also store variables, they are often saved on your hard disk;
Read MoreSetting Line Height in CSS
The height of a line can be defined by the CSS line-height property. It accepts only positive values.SyntaxThe syntax of CSS line-height property is as follows −Selector { line-height: /*value*/ }ExampleThe following examples illustrate the CSS line-height property. Live Demo div * { margin: 1.5em; box-shadow: -13px -10px 10px 1px crimson; } #demo { line-height: 60%; } p { box-shadow: 13px -10px 10px 1px grey; line-height: 50px; } Demo Heading This is demo text one. This is demo text two. This is demo text three. OutputThis ...
Read MoreControlling the Position of Table Caption using CSS
The CSS caption-side property is used to vertically position the table caption box. It can take top and bottom as values. By default, table caption is placed at the top.SyntaxThe syntax of CSS list-style property is as follows−Selector { caption-side: /*value*/ }ExampleThe following examples illustrate the CSS caption-side property. Live Demo table * { border: ridge skyblue; padding: 0.5rem; } table { margin: 20px; box-shadow: 0 0 6px 3px indianred; empty-cells: show; } caption { border-top-style: none; caption-side: bottom; border-color: darkkhaki; border-radius: 50%; } ...
Read MoreCross Browser Solution for Image Marker in CSS
In order to display an image marker properly in all browsers, a cross-browser solution is required. The text alignment after the image marker is sometimes distorted. To achieve a uniform output, we specify the image to be used as a marker as background and align it accordingly.ExampleThe following examples illustrate styling of lists − Live Demo ul{ list-style-type: none; padding: 0px; margin: 0px; font-size: 1.5em; } ul li{ background-image: url("https://www.tutorialspoint.com/images/spring.png"); background-repeat: no-repeat; background-position: 0px 5px; padding-left: 24px; } Tutorials Java C# C C++ Spring Hibernate ...
Read MoreCSS Background Properties
CSS background properties help us style the background of elements. The CSS background property is a shorthand for specifying the background of an element. background-color, background-image, background-repeat, background-position, background-clip, background-size, background-origin and background-attachment together comprise the CSS background properties.SyntaxThe syntax of CSS background property is as follows−Selector { background: /*value*/ }ExampleThe following examples illustrate CSS background property − Live Demo #main { margin: auto; width: 300px; background-image: url("https://www.tutorialspoint.com/hadoop/images/hadoop-mini-logo.jpg"); background-repeat: no-repeat; background-size: cover; } #im { height: 200px; width: 200px; background-image: url("https://www.tutorialspoint.com/images/css.png"); background-repeat: no-repeat; background-position: center; } ...
Read More