I'm attempting to utilize JavaScript to change the background color of a panel in order to create a "selected" effect.
Upon clicking, I retrieve the div by its ID and modify its background color.
Although it initially works as intended, the background color reverts back almost immediately, and I'm unsure why this is occurring.
DJANGO HTML Template
<div class="panel-group">
{% if articles %}
{% for article in articles %}
<div class="panel panel-success" id="aid_{{ article.articleId }}">
<div class="panel-body">
<a href="" onclick="populateArticle({{ article.articleId }})" style="font-size: 1.2em"><b>{{ article.title }}</b></a><br/>
<span style="color:darkgrey; font-size:.9em; font-family:sans-serif; font-style:italic">{{ article.source }} - {{ article.date }}</span><br/>
{{ article.sentences }}
</div>
</div>
{% endfor %}
{% else %}
NO ARTICLES PRESENT
{% endif %}
</div>
Javascript
function populateArticle(aid) {
document.getElementById('aid_'+aid).style.backgroundColor="#DEF1DE";
}
Here is a link to a gif demonstrating the issue: (copy-paste the link in a new tab if it gives an error).
Any insight into why this behavior is happening would be greatly appreciated.