I\'d like to append a random string to an element\'s attribute, using either jQuery or javascript.
I need to reference a CSS f
Keep it simple, apply the current timestamp in miliseconds to the URL:
// this fellow creates a link to the style sheet
// after the page has loaded
var link = $("");
link.attr({
type: 'text/css',
rel: 'stylesheet',
href: 'http://example.com/style.css?' + (new Date).getTime()
});
$("head").append( link );
Please note that this is really a bad idea, if you're not going to change your stylesheet much, just replace the URL manually in the files. There are tools for that purpose available (sed
under Linux-based systems)