title: Reload an element with javascript
body: <p>I am very new to JavaScript and I am trying to reload an element (a div) using only Javascript when that div is clicked.. </p>
  
  <p>I found the location.reload() function, but this reloads the whole page. That doesnt work for me, because on clicking the button I want to display the time it took to click that div.</p>
  
  <p>I won't put the code because it will overcomplicate the question. I am basically just wondering if there is a function like location.reload() I could use to target a specific element (div) so it reloads. </p>
  
  <p>Update: Here is the code:</p>
  
  <pre><code>&lt;h1&gt;Test your Reactions!&lt;/h1&gt;
  &lt;p&gt;click on the boxes and circles as quickly as you can&lt;/p&gt;
  
  &lt;p id="timeNeeded"&gt;&lt;/p&gt;
  
  &lt;div id="circle"&gt;&lt;/div&gt;
  
          &lt;script type="text/javascript"&gt;
  
          //defining variables
  var myColors = ["green", "blue", "red", "purple", "orange", "black"];
  var myShape = ["50px", "inherit"];
  
  var startTime, endTime, timeDiff;
  var randColor = myColors[Math.floor(Math.random() * myColors.length)];
  var randShape = myShape[Math.floor(Math.random() * myShape.length)];
  
  
  // defining function: Setting the color and shape of the box
  function setStyle () {
  
      var circle = document.getElementById("circle");
       circle.style.backgroundColor = randColor;
       circle.style.borderRadius = randShape;
  }
  
  // defining function: Set Start time
   function start() {
    startTime = new Date();
  }
  
  // defining end function and time difference
  function end() {
    endTime = new Date();
  }
  
  // starting time measure
  start();
  
  
  //exectute style
  setStyle();
  
  // Clicking the button
  document.getElementById("circle").onclick = function () {
  
  // reloads the page
  // location.reload();
  
  
  end();
  var timeDiff = endTime - startTime;
  
  }
    document.getElementById("timeNeeded").innerHTML = "Your reaction: " + timeDiff
  
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>