I have image in container and I have set width and height attributes for this image in CSS. But I need to add loading image and it is smaller than actual pictures that will be shown in container, so I need to change size of image while it is loading. But when I set width and height attributes, image is shown in size that is set in CSS.
$(img).attr("src", "loading.gif");
$(img).show();
$(img).attr("width", "100px");
$(img).attr("height", "100px");
You’re confusing attributes with CSS:
Of course this assumes that
imgis actually representing an image:If you don’t have an image, you’ll need to create one, and append it to the DOM: