So I have a very long div that I need to maintain the scroll-position for when a user submits a form. Since I've never used JavaScript properly before I have no clue as to how to do that. Searching for the answer has not provided a useable answer. What I have gathered is that because I use jQuery, I might be able to use .scrollTop(), but more than that I do not know.
Below a rough sketch of the html page and how it looks:
<html>
<head>
<title>Untitled Document</title>
<style>
#article-text {
height: 100px;
overflow: scroll;
}
</style>
</head>
<body>
<div>
Some random text.
</div>
<div id="article-text">
Very, very long text.
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
Even more text.
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
That is how long the text is
</div>
<div class="form-nav">
<input type="submit" name="add_event" value="Add Event">
</div>
</body>
</html>
On clicking "Add Event", a POST request is sent and the page is reloaded:
views.py
elif 'add_event' in request.POST:
cp = request.POST.copy()
How do I save the scroll progress in the "article-text" div? Not the whole page, but that div specifically. Would love any pointers here.