A Pen by Josh Studley on CodePen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FloatLabel = (() => { | |
// add active class | |
const handleFocus = (e) => { | |
const target = e.target; | |
target.parentNode.classList.add('active'); | |
target.setAttribute('placeholder', target.getAttribute('data-placeholder')); | |
}; | |
// remove active class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// an array of colors | |
let colors = ['red', 'green', 'blue']; | |
// a function to build a list | |
let makeTemplate = function (data) { | |
let newList = ''; | |
data.forEach(function(element) { | |
newList += `<li>${element}</li>`; | |
}); | |
return newList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form id="signUpForm"> | |
<input type="email" id="emailField" required> | |
<button id="okButton" disabled>OK</button> | |
</form> | |
<script> | |
const signUpForm = document.getElementById('signUpForm'); | |
const emailField = document.getElementById('emailField'); | |
const okButton = document.getElementById('okButton'); | |