그래서이 웹 페이지는 왼쪽에 사진 갤러리가 있습니다. 이상적으로 그 위에 마우스를 가져 가면 오른쪽으로 불어 오는 그림이 바뀌지 만 축소판 아래의 상자에있는 텍스트도 바뀌어야합니다. this guide I was directed to earlier을 사용하여, 나는 건축하기 시작했다.JavaScript를 사용하여 다른 div의 텍스트 변경을 유도하는 데 어떻게 호버링을 사용할 수 있습니까?
모든 것이 바뀌어도 해당 포럼의 코드에서 모든 것이 올바르게 작동합니다. 그러나, 갤러리에 필요한 테이블 내의 div 안에 넣으면 부서지기 쉬운 것 같습니다. 텍스트는 내가 기본값으로 설정 한 것과 결코 바뀌지 않습니다. 개별 div의 mouseover에 응답하기 위해 머리글의 실제 스크립트를 변경해 보았지만 그 중 하나를 수행하지 않은 것으로 보입니다.
document.getElementById(). innerHTML을 올바르게 사용하고 있습니까? 내가 생각할 수있는 유일한 점은 스크립트를 변경하면 JavaScript가 깨 졌거나 출력 텍스트 상자와 다른 div에 그림을 식별하는 JavaScript div를 배치하여 불행하게 만들었습니다. 혹시라도 저를 올바른 방향으로 안내해 주시겠습니까?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Single Mouseover</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var dogtext='The domestic dog (Canis lupus familiaris), is a subspecies of the gray wolf (Canis lupus), a member of the Canidae family of the mammilian order Carnivora.'
var cattext='The domestic cat (Felis catus or Felis silvestris catus) is a small, usually furry, domesticated, carnivorous mammal.'
var parrottext='Parrots, also known as psittacines are birds of the roughly 372 species in 86 genera that make up the order Psittaciformes, found in most tropical and subtropical regions.'
var lizardtext='Lizards are a widespread group of squamate reptiles, with more than 5600 species , ranging across all continents except Antarctica as well as most oceanic island chains.'
var horsetext='The horse (Equus ferus caballus) is one of two extant subspecies of Equus ferus, or the wild horse.'
var chickentext='The chicken (Gallus gallus domesticus) is a domesticated fowl, a subspecies of the Red Junglefowl.'
function writetext(){
document.getElementById('p1').innerHTML=dogtext;
document.getElementById('p2').innerHTML=cattext;
document.getElementById('p3').innerHTML=parrottext;
document.getElementById('p4').innerHTML=lizardtext;
document.getElementById('p5').innerHTML=horsetext;
document.getElementById('p6').innerHTML=chickentext;
}
</script>
<link href="TextSwapTestCSS.css" rel="stylesheet">
</head>
<body>
<td width="1000" rowspan="3">
<div id="gallery">
<ul>
<div id="p1" onmouseover="writetext(dogtext)" ><li><a href="dog.jpg"><img src="dog.jpg" width="100" height="75" alt="dog">
<span><img src="dog.jpg" width="400" height="300" alt="dog"><br>This is a cool looking dog.</span></a></div>
</li>
<li><div id="p2" onmouseover="writetext(cattext)" ><a href="cat.jpg"><img src="cat.jpg" width="100" height="75" alt="cat">
<span><img src="cat.jpg" width="400" height="300" alt="cat"><br>Just a cute kitten.</span></a></div>
</li>
<li><div id="p3" onmouseover="writetext(parrottext)" ><a href="parrot.jpg"><img src="parrot.jpg" width="100" height="75" alt="parrot">
<span><img src="parrot.jpg" width="400" height="300" alt="parrot"><br>A rainbow parrot just hanging out.</span></a></div>
</li>
<li><div id="p4" onmouseover="writetext(lizardtext)" ><a href="lizard.jpg"><img src="lizard.jpg" width="100" height="75" alt="lizard">
<span><img src="lizard.jpg" width="400" height="300" alt="lizard"><br>A green lizard just chillin'.</span></a></div>
</li>
<li><div id="p5" onmouseover="writetext(horseext)" ><a href="horse.jpg"><img src="horse.jpg" width="100" height="75" alt="horse">
<span><img src="horse.jpg" width="400" height="300" alt="horse"><br>A horse running through a field.</span></a></div>
</li>
<li><div id="p6" onmouseover="writetext(chickentext)" ><a href="chicken.jpg"><img src="chicken.jpg" width="100" height="75" alt="chicken">
<span><img src="chicken.jpg" width="400" height="300" alt="chicken"><br>A chicken in an alley.</span></a></div>
</ul>
<div id="textarea" style="height:250px;width:220px;font:16px;font:16px/26px Arial, Helvetica, sans-serif;overflow:scroll; position:relative;
top:300px; left:-230px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi pulvinar lectus non lectus auctor egestas. Donec at nunc neque. Morbi ornare condimentum lobortis. Nam vehicula urna ac mauris pharetra rutrum. Duis et arcu eget sapien interdum porttitor ut et tortor. Maecenas ultricies dignissim pretium. Integer quis enim metus. Sed enim lacus, eleifend eu euismod volutpat, blandit eu sem. Vestibulum varius purus ut est accumsan pellentesque. Donec quis enim id lectus sollicitudin suscipit at volutpat augue. Curabitur et metus purus. Fusce luctus nunc vitae sapien pharetra id accumsan lectus malesuada.</div>
</div>
</td>
</body>
</html>
<!--HERE BEGINS THE CSS TO MAKE THE GALLERY WORK-->
#gallery {position: relative; }
#gallery ul {list-style-type: none;
width: 300px; }
#gallery li { display: inline;
float: left;
padding: 10px; }
#gallery img {border-style: solid: 10px; border-color: #333; }
#gallery a { text-decoration: none;
font-style: none;
color: #333; }
#gallery span {display: none; }
#gallery a:hover span {display: block;
position: absolute;
top: 10px;
left: 300px;
text-align: center; }
여기서 매개 변수를 정의 할 수 있습니까? –