- <html>
- <head>
- </head>
- <body>
- <script type="text/javascript" src="mootools2.js"></script>
- <script type="text/javascript">
- window.addEvent('domready', function(){
- function rgb() {
- var r = $random(0, 220);
- var g = $random(0, 220);
- var b = $random(0, 220);
- var rgb = [r,g,b].rgbToHex();
- return rgb;
- }
- $("#colarray .barcode").addEvents({
- 'mouseover': function(){
- this.morph({
- 'background-color': rgb()
- });
- },
- 'mouseleave': function(){
- this.morph({
- 'background-color': rgb()
- });
- }
- });
- });
- </script>
- <style>
- #colarray {
- width: 200px;
- height: 200px;
- border: 1px;
- }
- .barcode {
- background-color: #251151;
- }
- </style>
- <div id="colarray">
- test
- <div class="barcode">test2</div><br>
- <div class="barcode">test222</div><br>
- <div class="barcode">test2222</div><br>
- </div>
- </body>
- </html>
Here is my not working code:
But if i use this $('barcode') instead of $("#colarray .barcode")
And one div block will have id="barcode" (this id will be determined in style) So, this block wil change the color... So is there any possibility to make it work as i want?


