Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <style type="text/css">
- span {
- padding: 5px;
- display: inline-block;
- }
- .hi-light {
- background-color: yellow;
- }
- </style>
- <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
- <script type="text/javascript">
- jQuery(function(){
- var numberToDisplay = 1000;
- var arr = Array.apply(0,new Array(numberToDisplay)).map(function(_,i){ return i+1 });
- arr = arr.sort(function(a,b){return Math.random()>0.5});
- function getFactors(integer){
- var factors = [],
- quotient = 0;
- for(var i = 0; i < arr.length; i++){
- quotient = integer/arr[i];
- if(quotient === Math.floor(quotient) && integer !== arr[i]){
- factors.push(arr[i]);
- }
- }
- return factors;
- }
- $.each(arr, function(i, v){
- var el = $('<span class="el-'+v+'" value="'+v+'" />').html(v);
- $('body').append(el);
- el.on('mouseover',function(){
- $.each(getFactors($(this).attr('value')), function(ii, vv){
- $('span.el-'+vv+'').addClass('hi-light');
- })
- }).on('mouseout', function(){
- $('span').removeClass('hi-light');
- })
- })
- })
- </script>
- </head>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement