function altToH1(){
document.getElementById("Obsada").innerHTML = "alt";
}
.flip-card {
background-color: transparent;
width: 200px;
height: 300px;
perspective: 1000px;
display: inline-block;
}
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.6s;
transform-style: preserve-3d;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
}
.flip-card:hover .flip-card-inner {
transform: rotateY(180deg);
}
.flip-card-front, .flip-card-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.flip-card-front {
background-color: #5bccf6;
color: white;
font-weight: 900;
}
.flip-card-back {
background-color: #5bccf6;
color: white;
transform: rotateY(180deg);
}
<div class="Obsada">
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<h1></h1>
</div>
<div class="flip-card-back">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f1/Heart_coraz%C3%B3n.svg/800px-Heart_coraz%C3%B3n.svg.png" alt="test test" style="width:200px;height:300px;">
</div>
</div>
</div>
**
The point is that without filling h1 , using Javascript, it should be automatically filled in from the "alt" text of the photo.
For example: ‘h1 /h1’ to replace ‘h1’photo alt text’ /h1’**
I am not experienced in coding so please bear with me
2
Answers
You have a few problems here:
Obsada
element seems to be missing a closing</div>
taggetElementById
to select an element that does not have an ID. It has a classclass='Obsada'
altToH1()
function but you never call it anywhere, so it never runs.So to fix these issues, I am going to:
<div>
tag at the endalt
text and put it where you wantif you want to wright "alt" in h1 tag you should mentioned h1 in script code like:
document.querySelector(".Obsada h1").innerHTML ="alt"