JSFiddle - React, Tailwind, and code Playground
HTML
<input id="inpText" value="이름을 입력해주세요">
<div class="attr">
<strong>element.getAttribute('value') :</strong>
<span class="result"></span>
</div>
<div class="prop">
<strong>element.value :</strong>
<span class="result"></span>
</div>
JavaScript
let inpEle = document.querySelector('#inpText');
const getValue = () => {
const getValue = function(){
let attrEle = document.querySelector('.attr .result');
let propEle = document.querySelector('.prop .result');
let attrVal = inpEle.getAttribute('value');
let propVal = inpEle.value;
attrEle.textContent = attrVal;
propEle.textContent = propVal;
}
getValue();
return getValue;
};
inpEle.addEventListener('input', getValue);