Robin Cox
Robin Cox

Reputation: 1490

Load images onto page with jQuery

Is there a way to load images into the dom after document is ready? In this example for instance, I wan't the image "photo" loaded onto the page when every other element has loaded:

<body>
  <div>
    <img id="photo" src="img/photo.jpg" alt="a furry little cat" />
    <p>Lorrem ipusum</p>
  </div>
</body>

Upvotes: 0

Views: 44

Answers (1)

RKS
RKS

Reputation: 1410

Have you considered adding the control dynamically to the DOM ?

Just give your div an id and access it using jQuery and supply the required HTML like so

$('#div').html('<img id="photo" src="img/photo.jpg" alt="a furry little cat" />');

You can do this inside $(document).ready(); so that it loads after every other page element is loaded.

Upvotes: 1

Related Questions