I am trying to provide a function on an html page with which I can zoom in and out text.
I already tried with all available browsers. Here is my code:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#zoomtext
{
transform: scale(1);
transition: transform 0.2s ease-in-out;
}
</style>
<script>
window.addEventListener("load", function()
{
var zoom = 1;
var zoomStep = 0.2;
});
document.getElementById("zoomIn").addEventListener("click",function(){zoom += zoomStep; document.getElementById("zoomtext").style.transform = "scale("+zoom+")";});
document.getElementById("zoomOut").addEventListener("click",function(){if(zoom > zoomStep){zoom -= zoomStep; document.getElementById("zoomtext").style.transform = "scale("+zoom+")";}});
</script>
</head>
<body>
<button id="zoomOut">-</button>
<button id="zoomIn">+</button>
<article>
<section id="zoomtext">
<p>This is a text that I want to be able to zoom in and out by means of the two buttons indicating plus and minus.</p>
</section>
</article>
</body>
</html>
There is no error message. Nothing happens upon click.