Increase Value on Click

    0

    0

    Marvin Blach

    Javascript

    The code will first set the variable i to 2. Then, when the user clicks the "trigger" element, the code will create a new "counter" element and will increment i within it.

    $(function(){ // you can wrap it here with in document ready block
      var i = 2;
      $(".trigger").click(function(){
          $("#counter").html("0" +i++);
      });
    });
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.