So I do have a profile image in my project, and I want it to have a green border. But everytime I reload the page, the image dissapears for a short moment, but to border still remains. I wanted to ask if there is any way, maybe with JavaScript to remove the border-element in css if the image is not loaded yet
This is my html:
<img src="somepic.png" id="user_img" class="user_img">
and this is my css:
.user_img{
border: 2px solid rgb(136, 186, 60);
}
I already tried this with jquery:
if(!$("#user_img").complete){
$("#user_img").removeClass("user_img")
}
But this doesn’t really work dynamically, so the border would just dissapear forever. Is there any way to check on reload and only add the border if the image is fully loaded?
3
Answers
Try to add border with js
js
Set default
border:none
, create class with border style and add it by JS after load.You can use a bit of Javascript to handle this.