title: How to pass the class name of a clicked div as a parameter to a function
body: <p>This may be basic but I could not find the result I needed in JAVASCRIPT from the research I did.</p>
  
  <p>there are two number variables. they are "mainnumber" and "buttonnumber"
  mainnumber is generated from math.random.
  buttonnumber is the number that is at the end of the different  class names. 
  That means buttonnumber = 1 when the clicked div has the class name class='example1'
  That means buttonnumber = 2 when the clicked div has the class name class='example2' etc.</p>
  
  <p>there are about 50 divs that have their own class name as example1,example2 etc. some class names are repeated among divs.</p>
  
  <p>when a button is clicked a function "compareaction" is called to compare "mainnumber" and "buttonnumber" and do a different function called 
  "resultcorrect" or "resultwrong" depending on the comparison.</p>
  
  <p>// comparison code here</p>
  
  <pre><code>function compareaction(buttonnumber){
      if (mainnumber == buttonnumber){
          resultcorrect();    
      } else {
          resultwrong();
      }
  }
  </code></pre>
  
  <p>I need to know how to pass the number at the end of class name (that is 1 or 2 or 3 or 4 etc) to the function.</p>
  
  <pre><code>&lt;div class="example1" onclick="compareaction(\\number in class name as a parameter)"&gt;&lt;/div&gt;
  </code></pre>