前端学堂 http://www.felearn.com
当前位置首页 > 前端技术 > JavaScript> 正文

javascript控制图片点击小图切换

2021-05-16 11:41:25 暂无评论 JavaScript 多张   javascript   获得

很简单,上百度hi我。。我给你提供代码。。

你的文件是什么?这个效果很好实现的,既然不要什么切换效果,就更容易了,你可以先把你写的代码让我看看,帮你修改下,也对你有提高,我要是把单纯的代码发给你,对你学习的效果也不大~

javascript 怎么获得多张图片ID?

<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </title> <meta name="generator" content="editplus" /> <meta name="author" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /> </head> <body> <div id='div'> <div style="position:absolute; visibility:hidden; left: 45px; top: 145px;"><img id="img1" src="images/4.jpg" name="img" width="80" height="65"/></div><div style="position:absolute; visibility:hidden; left: 262px; top: 145px;"><img id="img2" name="img" src="images/4.jpg" width="80" height="65"/></div><div style="position:absolute; visibility:hidden; left: 79px; top: 15px;"><img id="img3" name="img" src="images/4.jpg" width="80" height="65"/></div><div style="position:absolute; visibility:hidden; left: 89px; top: 210px;"><img id="img4" name="img" src="images/4.jpg" width="80" height="65"/></div> </div> </body></html><script type="text/javascript"><!-- var image=document.getElementById('div').getElementsByTagName('img'); for(i=0;i<image.length;i++){ alert(image[i].id); }//--></script>这样就可以了

javascript 怎么获得多张图片ID?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title> <script language="javascript" type="text/javascript">var obj ="";for(i=1;i<=4;i++){obj += "img" + i + " ";}alert(obj);</script> </head> <body> <div id="img1" style="position:absolute; visibility:hidden; left: 45px; top: 145px;"><img src="images/4.jpg" name="img" width="80" height="65"/></div><div id="img2" style="position:absolute; visibility:hidden; left: 262px; top: 145px;"><img name="img" src="images/4.jpg" width="80" height="65"/></div><div id="img3" style="position:absolute; visibility:hidden; left: 79px; top: 15px;"><img name="img" src="images/4.jpg" width="80" height="65"/></div><div id="img4" style="position:absolute; visibility:hidden; left: 89px; top: 210px;"><img name="img" src="images/4.jpg" width="80" height="65"/></div></body> </html>你要这样的效果??

javascript 怎么获得多张图片ID?