title: how to generate and append a random string using jquery
body: <h2>Generalities</h2>
  
  <p>I'd like to append a random string to an element's attribute, using either jQuery or javascript.</p>
  
  <h2>Specifics</h2>
  
  <p>I need to reference a CSS file that lives on a CDN. Unfortunately, the CDN changes the URL of this CSS file every time the file is updated. So I can't simply refer to a static URL.</p>
  
  <p>It turns out tho, that if you append a string to the end of the URL that the CDN has never seen before, it will return the most recent version of the file. Bogus to be sure.</p>
  
  <p>e.g. </p>
  
  <pre><code>&lt;link href="http://example.com/style.css?randomString-neverSeenBefore"&gt;
  </code></pre>
  
  <p>I know, this is ugly, faulty and insane. But sometimes that's how the cookie crumbles. The alternative would be to attempt to maintain, in parity, a growing battery of CSS files and template headers... not viable. ;) </p>
  
  <h2>What I've got so far,</h2>
  
  <p>My jQuery skills are meager. I've found two different bits of code that do what I need on their own but I can't for the life of my figure out how to get them to work together. </p>
  
  <h3>bit of code #1:</h3>
  
  <pre><code>        // this guy is a random number generator that i found
          jQuery.extend({
          random: function(X) {
              return Math.floor(X * (Math.random() % 1));
          },
          randomBetween: function(MinV, MaxV) {
            return MinV + jQuery.random(MaxV - MinV + 1);
          }
      });
  
  
      // using above plugin, creates 20 random numbers between 10 and 99
      // and then appends that 40 digit number to a paragraph element
      for (i = 0; i &lt; 20; i++) {
          $('p').text(    
              $('p').text() + ($.randomBetween(10, 99) )
              );
      }
  </code></pre>
  
  <h3>bit of code #2:</h3>
  
  <pre><code>    // this fellow creates a link to the style sheet
      // after the page has loaded
      var link = $("&lt;link&gt;");
      link.attr({
              type: 'text/css',
              rel: 'stylesheet',
              href: 'http://example.com/style.css'
      });
      $("head").append( link ); 
  </code></pre>
  
  <p><em>I assume "bit of code #2" is required</em>: my presumption is that were I to simply appended a random number to the end of an existing "href" attribute, nothing would happen. i.e. the CSS file <strong>would not</strong> be reloaded.</p>
  
  <p>Thanks a million for your help on this! :) </p>
  
  <p>Jon</p>