eje1.html 1.22 KB
Newer Older
Joel Florentin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
<html>
    <head>
        <title>js exercises</title>
    </head>
    <body>
        <form>
            <fieldset>
                <legend>Email subscriptions</legend>        
                <p id="Ross">
                <label for="subscribe">
                    <input type="checkbox" name="subscribe" id="subscribe">
                    Yes! I would like to receive all of you free candy!
                </label>
                </p>    
                <p id="emailPara">
                    <label for="email">
                        Email Address:
                        <input type="text" name="email" id="email">
                    </label>
                </p>
            </fieldset>
            
        </form>
        <script>
            email = document.querySelector("#emailPara");
            subscribe = document.querySelector("#subscribe");
            email.style.display = "none";
            subscribe.parentElement.style.backgroundColor = "blue";
            function toggleEmail(){
                email.style.display = document.querySelector("[name=subscribe]").checked?null:"none"
        
            }
            
            subscribe.addEventListener('click',toggleEmail);

        </script>
    </body>
</html>