【发布时间】:2014-02-18 08:02:35
【问题描述】:
我正在尝试隐藏、显示、移动图像,但我无能为力。我看到了按钮,但什么也没发生。 jQuery的链接是错误的还是其他的?我所做的一切似乎都不起作用。目前不知道该怎么办...
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>jQuery</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link type="text/css" rel="stylesheet" href="jquery.css"/>
<script type="text/javascript">
$(document).ready(function() {
$("img").addClass("wrappedElement");
$("#Hide All Images").click(function(){
$("img").hide("fast");
});
$("#Show All Images").click(function(){
$("img").show("fast");
});
$("#Show Even Images").click(function() {
if ($("img:even").is(':visible') && $("img:odd").is(':visible')) {
$("img:odd").toggle("fast");
}else{
$("img:even").show("fast");
}
});
$("#Show Odd Images").click(function(){
if ($("img:odd").is(':visible') && $("img:even").is(':visible')) {
$("img:even").toggle("fast");
}else{
$("img:odd").show("fast");
}
});
$("#Right Shift").click(function(){
$("img").slideRight();
});
$("#Left Shift").click(function(){
$("img").slideLeft();
});
});
</script>
<body>
<div id="header">
<button id="Hide All Images">Hide All Images</button>
<button id="Show Even Images">Show Even Images</button>
<button id="Show Odd Images">Show Odd Images</button>
<button id="Right Shift">Right Shift</button>
<button id="Left Shift">Left Shift</button>
</div>
<div id ="content">
<img class="photo" src="photo_one.jpg" alt="one">
<img class="photo" src="photo_two.jpg" alt="two">
<img class="photo" src="photo_three.jpg" alt="three">
<img class="photo" src="photo_four.jpg" alt="four">
<img class="photo" src="photo_five.jpg" alt="five">
</div>
</body>
【问题讨论】:
-
您的 jquery 链接缺少
http:作为前缀。 -
哦,不工作我认为你的意思是点击事件是由 mouseOvers 触发的?
-
@TravisJ 不需要。建议使用无协议 URI
-
@Phil - 很有趣,感谢您提供我没有听说过无协议 URI 的信息。
-
@Rooster,我的意思是点击按钮,什么都没有发生。
标签: javascript jquery html