It turns out that I can not make it show me as a url when I concatenate the url images/
that is the folder that I have to put images, the code that I put together is the following.
carouselImagen+= '<div class="carousel-item active" id="plantillaCarousel">'+
'<div class="view" style="background-image: url("images/'+data.carousel[i].imagen+'"); background-repeat: no-repeat; background-size: cover;">'+
'<div class="mask rgba-black-light d-flex justify-content-center align-items-center">'+
'<div class="text-center white-text mx-5 wow fadeIn">'+
'<h1 class="mb-4"><strong>'+data.carousel[i].tituloImagen+'</strong></h1>'+
'<p class="mb-4 d-none d-md-block">'+
'<strong>'+data.carousel[i].descripcion+'</strong></p></div></div></div></div>';
If you see the part correctly, style="background-image: url("images/'+data.carousel[i].imagen+'");
it generates it for me in the following way
<div class="carousel-item" id="plantillaCarousel">
<div class="view" style="background-image: url(" images="" 1.jpg");="" background-repeat:="" no-repeat;="" background-size:="" cover;"="">
<div class="mask rgba-black-light d-flex justify-content-center align-items-center">
<div class="text-center white-text mx-5 wow fadeIn">
<h1 class="mb-4">
<strong>Titulo de Imagen</strong></h1>
<p class="mb-4 d-none d-md-block">
<strong>Descripcion de la imagen</strong>
</p>
</div>
</div>
</div>
</div>
So I want to know if something should be done to concatenate there
PS: I am using jquery and for the layout using bootstrap oriented material design
The problem is in the line you specify
style="background-image: url("images/'+data.carousel[i].imagen+'");
When you put
style="background-image:url("
you are closing at this point the labelstyle
with the quotes that you want to use to open the url.In principle, I have always put the url as it is, without quotes or anything, but I understand that it is bad practice... You can do it in the following way:
style="background-image: url(\"images/'+data.carousel[i].imagen+'\");"
By putting
\"
you indicate that you want those quotes to be part ofstring
and not that they are the closing ofstyle
.That should work fine for you
You can use template literals to make it easier to write the string, since you need both quotes
"
and'
also concatenate variables:Notice that the left one is left
url
withbackground-image
the single quotes and the variable is inserted in the middle: