Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <div id="output"></div>  
</body>
</html>
 
span {
  display: inline-block;
  border: 1px solid red;
  padding: 2em;
}
 
var NUMBERS = 100;
function go() {
  var out = document.getElementById("output");
  for (var i = 1; i < NUMBERS+1; i++) {
    addSpan(i);
  }
  
  function hover(id, color, size) {
    var span = document.getElementById(id);
    span.style.backgroundColor = color;
    span.style.fontSize = size;
  }
  function addSpan(i) {
    var span_one = document.createElement("span");
    span_one.id = "span" + i;
    span_one.innerHTML = "" + i;
    out.appendChild(span_one);
    
    if (isPrime(i) === true) {
      span_one.style.backgroundColor = "red";
      span_one.onmouseover = function() {
        hover("span"+i, "yellow", "150%")
      };
      span_one.onmouseout = function() { 
        hover("span"+i, "red", "100%");
      };
    }
  }
}
function isPrime(i) {
  return true;
}
go();
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
chrisdaviespro
0viewers