我正在创建加勒比海盗主题网站。一组5张图像,每张图像显示该系列的一部电影。您单击一个图像,它显示文本,但是单击下一个图像不会删除前一个文本。您将如何去做?
使用函数使其正常工作:
function mytesty() {
var Header = document.createElement("p");
var addHeader = document.createTextNode("Pirates of the Caribbean: The Curse of the Black Pearl is a 2003 American fantasy swashbuckler film directed by Gore Verbinski and the first film in the Pirates of the Caribbean film series. Produced by Walt Disney Pictures and Jerry Bruckheimer, the film is based on Walt Disney's Pirates of the Caribbean attraction at Disney theme parks.[3] The story follows pirate Jack Sparrow (Johnny Depp) and blacksmith Will Turner (Orlando Bloom) as they rescue the kidnapped Elizabeth Swann (Keira Knightley) from the cursed crew of the Black Pearl, captained by Hector Barbossa (Geoffrey Rush), who become undead skeletons at night.");
Header.appendChild(addHeader);
var getFilms = document.getElementById("row")
Header.className = "col-lg-4 offset-lg-7";
Header.id = "lol";
getFilms.appendChild(Header);
}
function mytests() {
document.getElementById("lol").innerHTML = great;
}
var Header = document.createElement("p");
var addHeader = document.createTextNode("Pirates of the the ey undead skeletons at night.");
Header.appendChild(addHeader);
Header.className = "col-lg-2 offset-lg-10";
Header.id = "great";
<div class="Container " id="container">
<div class="background img2 bg">
</div>
<br>
<br>
<br>
<div class="row marginChange1" id="row">
</div>
<div class="row marginChange">
<div id="tests" class="col-lg-1 offset-lg-4 BlackPearl" onclick="mytesty();">
<img src="/Images/Pearl.jpg" class="img-fluid selection " alt="Curse of the Black Pearl">
</div>
<div class="col-1" onclick="mytests()">
<img src="/Images/pirates-of-the-caribbean-dead-mans-chest-poster_0.jpg" onclick=""
class="img-fluid selection DeadMan" alt="Dead Mans Chest">
</div>
<div class="col-1">
<img src="/Images/Worlds.jpg" class="img-fluid selection WorldsEnd" alt="At Worlds End">
</div>
<div class="col-1">
<img src="/Images/Stranger Tides.jpg" class="img-fluid selection StrangerTides" alt="Stranger Tides">
</div>
<div class="col-1">
<img src="/Images/Pirates_of_the_Caribbean,_Dead_Men_Tell_No_Tales.jpg"
class="img-fluid selection NoTales" alt="Stranger Tides">
</div>
</div>
<br>
```</div>