jquery。为什么只有我在画廊中的第一张图片显示;其他的只显示标题?
对不起,我还在学习呢。”我一整天都在试图解决这个问题。它过去工作得很好。我希望这个问题的格式正确 我有一个在右边边栏有4个缩略图的网页。 当我点击第一个按钮时,会显示一个更大的图像。 当我点击第二个、第三个和第四个“仅”时,alt标题和标题显示出来 下面是一些可能相关的代码。再一次,对不起。我一直在做这个项目,让它过去一周,现在我觉得有点失落jquery。为什么只有我在画廊中的第一张图片显示;其他的只显示标题?,jquery,html,image,gallery,Jquery,Html,Image,Gallery,对不起,我还在学习呢。”我一整天都在试图解决这个问题。它过去工作得很好。我希望这个问题的格式正确 我有一个在右边边栏有4个缩略图的网页。 当我点击第一个按钮时,会显示一个更大的图像。 当我点击第二个、第三个和第四个“仅”时,alt标题和标题显示出来 下面是一些可能相关的代码。再一次,对不起。我一直在做这个项目,让它过去一周,现在我觉得有点失落 <script type="text/javascript" src="../_scripts/jquery-1.3.2.min.js">
<script type="text/javascript" src="../_scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../_scripts/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript">
$(function(evt) {
$("a:has(img.gallery)").click(function() {
var largePath = $(this).attr("href");
var caption = $(this).attr("title");
$("#photo_large").attr({ src: largePath });
$("#caption1").text(caption);
return false;
});
});
</script>
// more code for mainNav here
<div id="identifier">
<img alt="The Ocean" height="90" src="../_images/200westCoastSunsetCyan.jpg" width="770" /></div>
<div id="sidebar">
<h3>Marconi Beach</h3>
<p>Cape Cod</p>
<a href="../_images/capeCodTooRoughToSwim1.jpg" title="Too Rouch To Swim"><img id="thumb_01" alt="cape set" class="gallery" height="160" src="../_images/t_capeCodTooRoughToSwim1.jpg" width="200" /></a>
<a href="../_images/capeCod122.jpg" title="Warm Water"><img id="thumb_02" alt="cape set" class="gallery" height="160" src="../_images/t_capeCod122.jpg" width="200" /></a>
<a href="../_images/capeCodBoogie1.jpg" title="boogie bording"><img id="thumb_03" alt="cape set" class="gallery" height="160" src="../_images/t_capeCodBoogie1.jpg" width="200" /></a>
<a href="../_images/capeCodHighUp.jpg" title="from the top of the steps"><img id="thumb_04" alt="cape set" class="gallery" height="160" src="../_images/t_capeCodHighUp.jpg" width="200" /></a>
</div>
<div id="mainContent">
<div id="subNav">
<ul id="lifestyleSubNav">
<li><a href="maps.htm">maps</a></li>
<li><a class="current" href="photos4.htm">Photos</a></li>
<li><a href="videos.htm">videos</a></li>
<li><a class="last" href="links.htm">links</a></li>
</ul>
</div>
<div id="photoSet">
<h1 class="clearLeft">Come to the Ocean.</h1>
<div id="photoGroup">
<img id="photo_large" alt="cape cod" height="345" src="../_images/capeCodTooRoughToSwim1.jpg" width="460" />
<p id="caption1" class="caption">It looks calm but there is an undertow.</p>
</div>
</div>
$(功能(evt){
$(“a:has(img.gallery)”)。单击(函数(){
var largePath=$(this.attr(“href”);
var caption=$(this.attr(“title”);
$(“#photo_large”).attr({src:largePath});
$(“#标题1”)。文本(标题);
返回false;
});
});
//这里有更多的mainNav代码
马尔克尼海滩
科德角
看起来很平静,但有一股暗流
来到海洋。
我想$(“a:has(img.gallery)”)
应该是$(“$('a').has(img.gallery)”)
你有没有试过show()
和hide()
,两分钟后就可以准备好了。还有漂亮的FadeIn效果等等。你试过这个吗:$(“a>img.gallery”)。在(“click”,function(){})
和$(“#photo_large”).attr('src',largePath)代码>我已经尝试了上述方法。不走运。我有class=“current”href=“photos.html”。这跟这事有关系吗?