I have a couple of divs that I created dynamically, which are added for documents that the user already seen.
doc_html.innerHTML = '<div id=' + doc_id + ' class="seen-doc"> <h5>You\'ve already seen this document.</h5></div>' + doc_html.innerHTML;
I also have this code to run when the user clicks the back button while on document, to return to the main menu. (I got this from https://stackoverflow.com/a/19196020/1122229)
<input type="hidden" id="refresh" value="no">
<script>
$(document).ready(function(e) {
var $input = $('#refresh');
$input.val() == 'yes' ? update_seen_docs() : $input.val('yes');
});
</script>
What I need update_seen_docs()
to do is look at the dynamic divs that I created earlier (with id equal todoc_id
) and check if they exist or not. I already have the list of doc_id
s that I want to check their existence. What I need is a way to check whether these dynamic div been created successfully by my earlier code.
I have tried putting this in my update_seen_docs()
doc_html = document.getElementById(doc_id);
if (doc_html){
# do stuff
}
but since the divs with doc_id
are dynamic, doc_html
is always null
.