How to create an increment of 10 value once you click a button in JavaScript?

JavascriptWeb DevelopmentObject Oriented Programming

For this, use click() along with parseInt().


 Live Demo

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<link rel="stylesheet" href="//">
<script src=""></script>
<script src=""></script>
<link rel="stylesheet" href="">
<div id="add">10</div>
<div id="sequenceValue"></div>
<button id="addSequenceOf10">addValue10EachTimePressMe</button>
   addValue = 0;
   $("#addSequenceOf10").click(function() {
      var actualValue = parseInt($("#add").html());
      addValue =addValue+ actualValue;

To run the above program, just save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VS Code editor.


This will produce the following output −

Now, press the button you will get 10 then 20 30 40…….N; as in the below output −

After clicking one more time, the snapshot is as follows.

This will produce the following output −

Updated on 12-Sep-2020 08:52:28