Skip to content

Instantly share code, notes, and snippets.

@dusekdan
Created May 11, 2017 14:45
Show Gist options
  • Save dusekdan/2e15bdaa6e059c4e2fe9276c75135790 to your computer and use it in GitHub Desktop.
Save dusekdan/2e15bdaa6e059c4e2fe9276c75135790 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
// Identificator of span which display mode should be altered
var SPAN_IDENTIFICATION = 'elementident';
function changeDisplayModeToBlock(elementId)
{
// Not that despite change of SPAN with ID is required, it is not
// neccessary to verify that element is SPAN. There should be only
// one occurence of ID in document, so if there is another element
// with given ID that is not SPAN, we would be applying the function
// to invalid document. Also it's probably not what they wanted to
// test anyways.
var element = document.getElementById(elementId);
element.style.display = 'block';
// Just put this here to see it more clearly
element.style.background = 'red';
}
</script>
</head>
<body onload="changeDisplayModeToBlock(SPAN_IDENTIFICATION)">
<span>
This span should not be affected.
</span>
<span id="elementident">
This is span which style property "display" should be changed by javascript to "block" (was "inline")
</span>
<span id="not-our-id">
Neither this span should be affected.
</span>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment