AmitDiwan has Published 10744 Articles

Explain touch events in JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Jul-2020 13:16:23

5K+ Views

The touch events in JavaScript are fired when a user interacts with a touchscreen device.Following are the pointer event propertiesEventDescriptiontouchstart.It is fired when the touch point is placed on the touch surface.touchmoveIt is fired when the touch point is moved along the touch surface.touchendIt is fired when the touch point ... Read More

Explain Key-events in JavaScript?

AmitDiwan

AmitDiwan

Updated on 16-Jul-2020 13:13:21

2K+ Views

The key-events happen whenever a user interacts with keyboard. There are mainly three key event types − keydown, keypress and keyup.EventDescriptionOnkeydownThis event fires when the user is pressing a keyOnkeypressThis event fires when the user presses the keyOnkeyupThis event fires when the user releases the key.Following is the code for ... Read More

Looping over matches with JavaScript regular expressions

AmitDiwan

AmitDiwan

Updated on 16-Jul-2020 12:59:28

878 Views

Following is the code for looping over regular expression matches in javaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result,    .sample {       font-size: 18px;       color: blueviolet; ... Read More

How to output JavaScript into a Textbox?

AmitDiwan

AmitDiwan

Updated on 16-Jul-2020 12:49:59

4K+ Views

You can use the concept of value(). Following is the JavaScript code −Example Live Demo Document FirstNumber SecondNumber: Add Two Nnumbers The addition is:    function add() {       var f = parseInt(document.getElementsByName('input1')[0].value);`       ... Read More

How to override derived properties in JavaScript?

AmitDiwan

AmitDiwan

Updated on 16-Jul-2020 12:48:16

353 Views

Following is the code to override derived properties in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result,    .sample {       font-size: 18px;       font-weight: 500;     ... Read More

Get value from div with JavaScript resulting undefined?

AmitDiwan

AmitDiwan

Updated on 16-Jul-2020 12:44:21

3K+ Views

Use document.getElementById().innerHTML for this. Following is the JavaScript code −Example Document    function display(){       var storedValue = document.getElementById('getValue').innerHTML.value="This is the       value";       console.log("The value is==="+storedValue);    } To run ... Read More

The onchange event is not working in color type input with JavaScript

AmitDiwan

AmitDiwan

Updated on 16-Jul-2020 12:41:48

984 Views

The onchange event triggers when an element changes. You need to use below syntax.onchange="yourFunctionName(this);"Example Live Demo Document Choose Color    function showValue(c){       console.log(c.value);    } To run the above program, save the file ... Read More

How to make Format ABC-1234 in JavaScript regular Expressions?

AmitDiwan

AmitDiwan

Updated on 16-Jul-2020 12:39:58

288 Views

Following is the JavaScript code to make a format like ABC-1234 −Example Live Demo Document ABC1234    function joinTheDashSymbol(m, r1, r2, r3, r4, r5) {       if (r1)          return [r1, r2, r3].join('-');       ... Read More

Get global variable dynamically by name string in JavaScript?

AmitDiwan

AmitDiwan

Updated on 16-Jul-2020 12:35:49

483 Views

Display in alert by using alert(window()). Following is the syntax −alert(window['yourVariableName' + 'yourVariableName' + otherVariableName]);Example Live Demo Document    var globalVariablelocal_print100=100;    print100=1;    alert(window['globalVariable' + 'local_' + print100]); To run the above program, save the file name anyName.html(index.html) ... Read More

Object de-structuring in JavaScript.

AmitDiwan

AmitDiwan

Updated on 16-Jul-2020 08:57:01

123 Views

Following is the code for object de-structuring in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample, .result {       font-size: 18px;       font-weight: 500;       color: ... Read More

Advertisements