<!DOCTYPE HTML>
<html>
<head>
<title>Palette Playing</title>
<script type="text/javascript">
var palette = "000000,0000FF,00FFFF,00FF00,FFFFFF,FF0000,FFFF00,FF00FF";
document.write(palette.split(',').splice(0, 4).join(','));
</script>
</head>
<body>
</body>
</html>
This will produce "000000,0000FF,00FFFF,00FF00".
Dominic Myers writes about all sorts of stuff to do with HTML, CSS, JavaScript and a fair chunk of self-indulgent stuff. Thoughts and opinions are all his own, and nothing to do with any employer.
Monday, 3 October 2011
Had the need to send a set of hex colour codes to a method which used them to create a chart using Google charts. The initial list was too short so that some of the colours ended up being repeated and the data became difficult to read. I pottered around the code base and "borrowed" some functionality from the boss. The following code is what I used to test it. By all means copy and paste it into a blank file and give it a try. Works a treat!
Labels:
JavaScript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment