pretty new here so apologies for all the questions. I’m making a scheduler that saves notes for different time brackets using jQuery and I’m at a snag where I’m unable to figure out how to have the button save data from a different element.
Sample of the HTML
<div id="17" class="times row time-block future">
<div class="col-2 col-md-1 hour text-center py-3">5PM</div>
<textarea class="col-8 col-md-10 description" rows="3"> </textarea>
<button class="btn saveBtn col-2 col-md-1" aria-label="save">
<i class="fas fa-save" aria-hidden="true"></i>
</button>
</div>
The JavaScript code I’ve been working on.
$(".saveBtn").on("click", function() {
var getId = $(this).parent().attr("id");
var getText = $(this).siblings(".description").val();
localStorage.setItem(getId, getText);
console.log(getId, getText)
preventDefault($(this).siblings(".description").val());
});
I’m looking to have preventDefault keep the text input in the textarea but unsure how to do that. I’m looking to have it save/still show the information on refresh. Thank you!
I’m still new so I’m still learning how everything works together. Thank you very much!