Answer the question
In order to leave comments, you need to log in
Saving text to input?
Hello! I have a question, I need to save the text entered by the user after pressing the save button in the input, here is the code
<textarea id="comment"></textarea>
<input type="text" id="fio">
<script>
var elements = document.querySelectorAll('input, textarea');
function checkValidity() {};
for (i=0; i<elements.length; i++) {
(function(element) {
var id = element.getAttribute('id');
element.value = sessionStorage.getItem(id); // обязательно наличие у элементов id
element.oninput = function() {
sessionStorage.setItem(id, element.value);
checkValidity();
};
})(elements[i]);
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question