-1
I need to change the image inside the div if the width of the screen is less than or equal to 991. I’ve done the code below, but it’s not working, I need to know where I’m going wrong and how to fix it.
html
<div class="dImg">
<img class="dImg2" src="assets/img/path.svg">
</div>
javascript
$(window).load(function teste() {
var tamanho = window.innerWidth;
if (tamanho <= 991) {
$(".dImg2").remove();
$(".dImg").append("<img src="
assets / img / path991.svg ">");
};
});
Also test with this js
$(window).load(function teste() {
var tamanho = window.innerWidth;
if (tamanho <= 991) {
$('.dImg2')
.attr("src")
.replace("assets/img/path.svg","assets/img/path991.svg");
};
});