Hi I have a simple html structure
Title text inner text
What I want is to replace only the te
const ChgBtn = document.querySelector('#change-title')
const title = document.querySelector('#page-title')
ChgBtn.addEventListener('click', (event) => {
if (title.innerHTML === 'job') {
title.innerHTML = 'better job'
event.target.innerHTML = 'Change title back'
}
else if (title.innerHTML === 'better job') {
title.innerHTML = 'job'
event.target.innerHTML = 'Change Title'
}
else {
console.error('Wrong')
}
})