我想用slidetoggle()
函数来做我用过的多件事但是它不会工作你能不能帮助我
javaScript代码解释了我即将要做的事情我将创建三个面板和三个点击来激活这些面板,但它没有工作
[enter image description here`<script>
$(document).ready(
function(){
$("#flip").click(function(){$("#panel").slideToggle("slow");});
}
function(){
$("#flip").click(function(){$("#panell").slideToggle("slow");});
}
function(){
$("#flip").click(function(){$("#panelll").slideToggle("slow");});
}
);
</script>`]
[1]
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/** {
outline: 1px solid black;
}*/
#header_buttons {
text-align: right;
padding-top: 10px;
height:150px;
}
#header_buttons a:hover{text-decoration: underline;}
#header_buttons li, a {
color: gray;
text-decoration: none;
display: inline;
list-style: none;
padding: 4px;
font-family: Arial;
font-size: 13px;
}
#sign_in {
display: inline-block;
border-radius: 3px;
background-color: #29A0F0;
padding-top: 0px;
margin-right:15px;
padding-bottom: 30px;
}
li#sign_in {
display: block;
margin-top: 10px;
}
#sign_in:hover{box-shadow: 0px 1px 0px 0px #e6e6e6;}
#sign_in a {
margin: 0 auto;
/* border:1px solid black;
*/
font-weight: bold;
text-align: center;
color: #FFFFFF;
}
#sign-in-text {
margin-top: 20px;
}
/*DAMN -- This was/is CONFUSING but it sets the sign-in button properties*/
div#header_buttons ul li#sign_in {
display: inline-block;
width: 70px;
height: 30px;
/* border: 1px solid black;
*/ text-align: center;
margin-bottom: 25px;
}
#sign_in a:hover {
text-decoration: none;
cursor: default;
}
#google_logo {
margin: auto;
margin-top: 50px;
margin-bottom: 10px;
}
#google_logo > img{
display: block;
margin: 0 auto;
}
#query {
width: 572px;
margin: auto;
}
#query > input {
width:572px;
height:30px;
margin: auto;
background-image: url("images/microphone.png");
background-position: right;
background-repeat: no-repeat;
background-size: contain;
}
#query input[type="text"] {
font-size: 17px;
}
.buttons {
width: 572px;
margin: auto;
margin-top: 5px;
text-align: center;
}
button#search {
margin-top: 10px;
font: bold 11px Arial, sans-serif !important;
width: 150px;
height: 33px;
-webkit-border-radius: 0px;
}
button#lucky {
font: bold 11px Arial, sans-serif !important;
width: 150px;
height: 33px;
}
#footer {
position: absolute;
bottom: 0;
padding-top: 10px;
padding-bottom: 10px;
min-height: 15px;
width: 100%;
height:33px;
/* border: 1px solid black;
*/ background-color: #e3e3e3;
}
#footer-left ul li{
float: left;
/* border:1px solid black;
*/ display: inline;
padding: 5px 3px;
padding-top: 14px;
vertical-align: bottom;
}
#footer-left ul li a{
/* border:1px solid black;
*/
padding: 30px 8px;
font-family: Arial;
font-size: 12px;
text-align: center;
}
#footer-right ul li
{
float: right;
display: inline;
padding: 30px 8px;
padding-top: 14px;
vertical-align: bottom;
}
#footer-right ul li a{
padding: 30px 8px;
font-family: Arial;
font-size: 12px;
text-align: center;
}
#flip {
text-align: center;
background-image:url("9blocks.png");
width:16px;
height:16px;
border: solid 1px #c3c3c3;
}
#panel {
display: none;
}
#panell {
display: none;
}
#panelll {
display: none;
}
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(
function(){
$("#flip").click(function(){$("#panel").slideToggle("slow");});
}
function(){
$("#flip").click(function(){$("#panell").slideToggle("slow");});
}
function(){
$("#flip").click(function(){$("#panelll").slideToggle("slow");});
}
);
</script>
<meta charset="UTF-8">
<title>Google</title>
<link rel="stylesheet" type="text/css" href="head.css">
</head>
<body>
<div id="header_buttons">
<ul>
<!-- <li id="gmail"><a style="margin-right:5px;margin-top:50px" href="https://mail.google.com/mail/?tab=wm">Gmail</a></li>
<li id="you"><a style="margin-right:35px;margin-top:50px" href="https://plus.google.com/?gpsrc=ogpy0&tab=wX">Images</a></li> -->
<li id="sign_in"><a id="sign-in-text" href="https://accounts.google.com/ServiceLogin?hl=en&continue=https://www.google.com/">Sign In</a></li>
<div id="flip" style="margin-left: 735px;margin-top: -47px;" ></div>
<div id="panel">
<img src="untitled.png" style="margin-left:635px;margin-top:0px;" width="179" height="200" alt="Planets" usemap"#planetmap">
<map name="planetmap">
<area shape="rect" alt="" title="" coords="4,1,49,54" href="1" target="_self" />
<area shape="rect" alt="" title="" coords="65,2,109,54" href="2" target="_self" />
<area shape="rect" alt="" title="" coords="124,1,174,59" href="3" target="_self" />
<area shape="rect" alt="" title="" coords="6,69,50,125" href="4" target="_self" />
<area shape="rect" alt="" title="" coords="63,66,110,126" href="5" target="_self" />
<area shape="rect" alt="" title="" coords="121,68,172,129" href="6" target="_self" />
<area shape="rect" alt="" title="" coords="6,140,47,192" href="7" target="_self" />
<area shape="rect" alt="" title="" coords="67,139,113,194" href="8" target="_self" />
<area shape="rect" alt="" title="" coords="128,142,172,194" href="9" target="_self" />
</map>
</div>
<div id="flip" style="margin-left: 635px;margin-top: -17px;" ></div>
<div id="panell">
<img src="untitled1.png" style="margin-right:210px;margin-top:0px;" width="61" height="200" alt="Planets" usemap="#planetmap">
<map name="planetmap">
<area shape="rect" alt="" title="" coords="4,1,49,54" href="1" target="_self" />
<area shape="rect" alt="" title="" coords="6,69,50,125" href="4" target="_self" />
<area shape="rect" alt="" title="" coords="6,140,47,192" href="7" target="_self" />
</map>
</div>
<div id="flip" style="margin-left: 535px;margin-top: -17px;" ></div>
<div id="panelll">
<img src="untitled2.png" style="margin-right:320px;margin-top:0px;" width="179" height="60" alt="Planets" usemap="#planetmap">
<map name="planetmap">
<area shape="rect" alt="" title="" coords="4,1,49,54" href="1" target="_self" />
<area shape="rect" alt="" title="" coords="65,2,109,54" href="2" target="_self" />
<area shape="rect" alt="" title="" coords="124,1,174,59" href="3" target="_self" />
</map>
</div>
<div class="button"> <i class="fa fa-th fa-2x"></i> </div>
</ul>
</div>
<div id="google_logo">
<img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png">
</div>
<div id=query>
<input type="text"></input>
</div>
<div class="buttons">
<button type="submit" value="Submit" id="search">Google Search</button>
<button id="lucky">I'm Feeling Lucky</button>
</div>
<div id="footer">
<div id="footer-left">
<ul>
<li><a href="https://www.google.com/intl/en/ads/?fg=1">Advertising</a></li>
<li><a>Business</a></li>
<li><a>About</a></li>
</ul>
</div>
<div id="footer-right">
<ul>
<li><a>Privacy & Terms</a></li>
<li><a>Settings</a></li>
</ul>
</div>
</div>
</body>
</html>
答案 0 :(得分:0)
您无法像这样传递多个回调,请尝试以下操作。
$(document).ready(function(){
$("#flip").click(function(){
$("#panel, #panell, #panelll").slideToggle("slow");
});
});
"#panel, #panell, #panelll"
将在单选择器中选择所有这三个元素。