Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Errors needed to fix</strong></p> <p>To fill the width of the <code>div</code> elements, the <code>a</code> elements need to be <code>display: block;</code> not their default <code>display: inline;</code>.</p> <p>Knowing runtime errors is more important in my opinion, and IDEs don't catch DOM errors or anything more complex than syntax; use the error logging in your browser (Firefox's is called Error Console). That'll also catch in-development errors like syntax errors.</p> <p>This is the most important point to stress: <code>block.style.left</code> and <code>block.style.top</code> are not just numbers with implicit pixel values in them. Setting it to a number without a unit suffix will do absolutely nothing. You need to add <code>%</code> or <code>px</code> or whatever unit when setting <code>left</code> and <code>top</code>.</p> <p>When getting the current value, as in <code>var x = ...</code> and <code>var y = ...</code>, you need to <code>Number()</code> manually to get the numeric portion of the string.</p> <p>Also, I believe you meant <code>|| block == null</code>, not <code>=</code>, which would set <code>block</code> to <code>null</code>.</p> <p><strong>Tips</strong></p> <p>You can use <code>moveBlock</code> instead of <code>"moveBlock();"</code> as an argument to <code>setTimeout</code>. This avoids parsing the string into code, and avoids scope problems (though not in this example as <code>moveBlock</code> is global).</p> <p>I know that you have an array of values, where both <code>x</code> and <code>y</code> move 10 each time. I assume you want to move at a 45 degree angle. If so, this won't work as you expect even after fixing all the errors as <code>x</code> is percentage and <code>y</code> is in pixels.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload