0
現在、私は小さなJSギャラリー(onmouseover)を持っています。コードは以下の通りです。私が達成したいのは、小さな画像です。一度に表示される画像はわずかです。私は私が達成したい影響を及ぼすのユーチューブの動画を発見した:videoギャラリー効果を高めるためのJavaScriptコード
HTML(コードは省略):
<div id="imagecontent">
<img id="about_mojang" src="images/about_mojang_small.jpg" alt="Plain Mojang Logo">
<img id="about_lego" src="images/about_lego_small.jpg" alt="Minecraft Lego">
<img id="about_cteam" src="images/about_cteam_small.jpg" alt="Cartoon of the Mojang team">
<img id="about_minecraftmojang" src="images/about_minecraftmojang_small.jpg" alt="Minecraft logo of Mojang">
<img id="about_team" src="images/about_team_small.jpg" alt="Photo of the Moajgn team">
<img id="about_wall" src="images/about_wall_small.jpg" alt="A wall in the Mojang office">
</div>
<div id="bigimage"></div>
<script>window.onload=addImages() ;</script>
</body>
JS(コードは省略):
function showPic(i_element) {
var source = i_element.getAttribute("id") ;
source = "images/"+source+".jpg" ;
var alt = i_element.getAttribute("alt") ;
var i = document.createElement("img") ;
i.setAttribute("src",source) ;
i.setAttribute("alt",alt) ;
var placeholder = document.getElementById("bigimage") ;
if (placeholder.childNodes.length != 0)
{ placeholder.removeChild(placeholder.childNodes[0]); }
placeholder.appendChild(i) ;
}
// add the onclick event to the DOM
function addImages() {
var item = document.getElementById("imagecontent").getElementsByTagName("img") ;
for (var i=0 ; i<item.length ; i++) {
item[i].onmouseover = function() {showPic(this) ; } ;
}
}
非常にうまくいきませんが、助けてくれてありがとうございます。 – Dan1676
私の例はあなたのビデオに似ていますか?そうではありませんか? – srini
私はそれがページ上の他のコーディングによるものだと思います。それはある時点まで働いていた。私はサイトの他のセクションで作業していますが、もう一度あなたの助けに感謝しているように、それは永遠に適合するようにコードの一部を編集する必要があります – Dan1676