I've tried a view alternatives from people who've asked similar questions. Here is the HTML:
<div class="col-md-6" style="height:480px;border:1px solid #fff">
<div id="view-port">
</div>
</div>
And here is the JavaScript that I've tried based on other answers from StackOverflow:
$(document).ready(function() {
document.getElementById("view-port").innerHTML="<img src='https://my.vetmatrixbase.com/clients/12679/images/cats-animals-grass-kittens--800x960.jpg' />";
});
or
$(document).ready(function() {
var elem = new Image();
elem.src = "https://my.vetmatrixbase.com/clients/12679/images/cats-animals-grass-kittens--800x960.jpg";
document.getElementById("view-port").appendChild(elem);
});
Neither of which seem to be working for me. The div just remains unaltered. If I directly inject the image tag inside the div within the HTML, it works; that's not, of course, what I'm trying to achieve though. I'm very new to JS, so any apologies if it ends up being a trivial mistake in my approach or code.
EDIT: I'm realizing that I'm tyring to do something different than my code reveals; using jQuery and JS at the same time, when I'm really just meaning to do JS. Sorry, like I said, I'm pretty new. I threw that code together from something else I found. What's the correct way to implement this?
FINAL EDIT: I made some extremely rookie mistakes, one of which was not paying attention to the relative path when I referenced the JS file. Thanks to everyone for all of their answers; I learned something from each one. Again, thank you guys so much!
$(document).readyis part of jQuery. You say you are using javascript. If you don't include jQuery, your code is going to run before the DOM is ready (page is loaded). Alternatively, you could usewindow.onloadinstead, to stick with straight javascript.