title: Make 1 javascript/function affect several classes at once - how?
body: <p>I am using the following code on my webpage, in order to format certain numbers (with the ".pricetag" class), as i need to show them as currencies (comma separated at thousands) on my front end:</p>
  
  <pre><code>jQuery(document).ready(function($) {
      $.fn.digits = function(text){
          $(this).text(text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") + '€' );
      };
      var tempText = $.trim($(".pricetag").text());
      tempText = tempText.substr(0, parseInt(tempText.length) );
      $(".pricetag").digits(tempText);
  });
  </code></pre>
  
  <p>So far so good - code works fine, and does what i need it to.</p>
  
  <p>My problem is that i have more classes than just the ".pricetag" class, for which i want to use the function. So right now i have copy pasted the code, and just changed the target class (".pricetag_2" etc.).</p>
  
  <p>How do i tell one version of the javascript/code, to affect several classes (both ".pricetag" and ".pricetag_2") in stead of having to copy paste the same piece of code, let's say 10 times, to target 10 different classes.</p>
  
  <p>It's a bit overkill to have so much code, as the function is exactly the same every time. In CSS it's pretty easy, as you can affect several classes at once, by comma seperating them within a piece of code, but how do i do it in javascript?</p>
  
  <p>Thanks!</p>