我试图在下拉菜单中嵌套一些缩略图,这些缩略图在激活时将出现在页面的不同区域。当我这样做时,JavaScript 无法正常运行。
$(document).ready(function(){
$("h4").append('<em></em>')
$(".thumbs a").click(function(){
var largePath = $(this).attr("href");
var largeAlt = $(this).attr("title");
$("#largeImg").attr({ src: largePath, alt: largeAlt });
$("h4 em").html(" (" + largeAlt + ")"); return false;
});
});
工作标记:
<section class="group1">
<h3>Print</h3>
<p class="thumbs">
<a class="clip" href="img/pen.png" title="awesome"><img src="images/picture1.jpg" /></a>
<a class="clip" href="img/pen.png" title="awesome"><img src="images/picture1.jpg" /></a>
<a class="clip" href="img/pen.png" title="awesome"><img src="images/picture1.jpg" /></a>
<a class="clip" href="img/pen.png" title="awesome"><img src="images/picture1.jpg" /></a>
<a class="clip" href="img/pen.png" title="awesome"><img src="images/picture1.jpg" /></a>
<a class="clip" href="img/pen.png" title="awesome"><img src="images/picture1.jpg" /></a>
<a class="clip" href="img/pen.png" title="awesome"><img src="images/picture1.jpg" /></a>
<a class="clip" href="img/pen.png" title="awesome"><img src="images/picture1.jpg" /></a>
<a class="clip" href="img/pen.png" title="awesome"><img src="images/picture1.jpg" /></a>
</p>
</section>
不适用于嵌套<li>
:
<ul id="expandmenu">
<li>Digital
<ol>
<p class="thumbs">
<li><a class="clip" href="img/pen.png" title="awesome"><img src="images/picture1.jpg" /></a></li>
<li><a target="iframe2" href="Change font color rainbow.htm">Rainbow Fonts</a></li>
<li><a target="iframe2" href="Cookies_ShowUserName.htm">ShowUserName</a></li>
</p>
</ol>
</li>
</ul>