p Hi!
span.showName
label Name
input.name(type="text")
button#save Save
View Compiled
*
line-height: 1.2rem
text-align: center
View Compiled
let btnSave = document.querySelector('#save')
let btnRemove = document.querySelector('#remove')
function saveName(){
let dataName = document.querySelector('.name').value
localStorage.setItem('userName', dataName)
}
function showName(){
let nameDom = document.querySelector('.showName')
nameDom.innerHTML = localStorage.getItem('userName')
}
showName();
btnSave.addEventListener('click', function(){
saveName();
showName();
})
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.