AmitDiwan has Published 10740 Articles

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

918 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

5K+ 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

374 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

1K+ 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

322 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

506 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

144 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

Array.prototype.sort() in JavaScript.

AmitDiwan

AmitDiwan

Updated on 16-Jul-2020 08:52:17

186 Views

The JavaScript Array.prototype.sort() method is used for sorting an array. The order of sorting can be alphabetic, numeric, ascending or descending.Following is the code for the Array.prototype.sort() method −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;   ... Read More

Advertisements