Tutorial merubah text button onclick menggunakan javascript

Buatlah file bernama test.html

kemudian ikuti script berikut

test.html
<html>
<head>
<title> merubah tombol text </title>
<style>
.button {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 8px 9px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    margin: 2px 0px;
    cursor: pointer;
     border-radius:10px;

}
</style>
<body>

<form>
<input type="button" class="button" onclick="change(this)"  value="OPEN" />
</form>

</body>

<script type="text/javascript">

function change(elem)
{
   if ( elem.value === "OPEN" )
   {
        elem.value = "CLOSED";
   }
   else
   {
        elem.value = "OPEN";

   }
}

</script>

</head>
</html>