Add a eventListener to element .click()

.click()


Description: Add a "click" eventListener to an element.


Example:

<!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>click demo</title>
      <script src="http://code.bitsycode.com/bitsycode-latest.min.js"></script>
    </head>
    <body>
      
      <div class="content-container"><span class="clickMe">Click me</span></div>
      
      <script type="text/javascript">
         
         bitsyCode.ready(function(){
            bitsyCode(".clickMe").click(function(){
               alert("SPAN was clicked.");
            })
         })
         
      </script>
     
    </body>
    </html>

Preview:

Click me
  • Usage

    • How to use:

      Add eventListener to an element. Allows for arguments to be passed to parameter function as a javascript object.

    • USAGE:

      bitsyCode("element").click(function, {});
    • Example: without arguments

      
      bitsyCode("element").click(myFunction);
      
      function myFunction(){
          //Add your code here
      }
                              
    • Example: with arguments

      
      bitsyCode("element").click(myFunction, { name: "BitsyCode" });
      
      function myFunction(args){
          alert(args.name); //BitsyCode
      }
                              
  • Options

    • What options are there:

      This method takes 2 parameters, a function parameter to be called after element is clicked on and a
      arguments parameter.

      These arguments will be sent to the function parameter as an object once the element has been clicked.

  • Returns

    • Returns: No return type

      Function specified will be fired once element is clicked on.

Share