jquery click on each class function code example

Example 1: how To clear all the input element inside div using jquery

By LOVE
$('#divStaffContent').find('input:text, input:password, select')
                    .each(function () {
                        $(this).val('');
                    });
                }

Example 2: function increase a number by click javascript

<body>
    <div id="poke"><button>click here</button></div>
    <div id="counter">0</div>


    <script type='text/javascript'>
    var poke = document.getElementById('poke');
    var cmp = document.getElementById('counter');
    poke.addEventListener('click', myfonction)




    //===========================================================
    function myfonction() {
      cmp.innerHTML = parseInt(cmp.innerHTML) +1;


    }

    </script>

  </body>

Tags:

Html Example