- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
if 段有效但 else 无效,当您尝试单击最小化按钮时可以看到,因为它会扩展但不幸的是不会收缩。
$("#scfullscreen").click(function() {
sccount+=1;
if (sccount % 2 !== 0) {
animateFn('20%','80%');
} else {
animateFN('0','20%');
}
});
问题是我不知道是什么导致它在这里不起作用是 javascript 的其余部分
var sccount = 0;
$(document).ready(function() {
$("#scfullscreen").click(function() {
sccount+=1;
if (sccount % 2 !== 0) {
animateFn('20%','80%');
} else {
animateFN('0','20%');
}
});
});
function animateFn(l, w){
$('#soundcloud').animate({
left: l,
width: w,
}, 1000);
$('#scfullscreen').animate({
left: l,
width: w,
}, 1000);
$('#scexpand').addClass('rotated');
}
这是我的 HTML
<!doctype html>
<html>
<head>
<title>L3mmy Dubz</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="jquery.js" type="text/javascript"></script>
<script src="animation.js" type="text/javascript"></script>
</head>
<body>
<div id="header"></div>
<a href="index.html">
<div id="homebtn" class="btn">Home</div>
</a>
<div id="musicbtn" class="btn">Music</div>
<iframe id="soundcloud" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/users/19690125&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"></iframe>
<div class="btn" id="scfullscreen" class="scfullscreenclick">
<img id="scexpand" height="100%" alt="fullscreen" src="images\plus.png" />
</div>
</body>
</html>
这是我的 CSS
* {
margin:0px;
border:0px;
padding:0px;
}
body {
background-color:#B22800;
height:100%;
width:100%;
}
#header {
position:fixed;
left:0px;
width:20%;
height:100%;
background-color: #7C1C00;
opacity:0.9;
}
.btn {
position:fixed;
line-height:200%;
text-overflow:clip;
display: block;
overflow: hidden;
white-space: nowrap;
height:7.5%;
width:20%;
color:white;
Font-size:2em;
text-align:center;
}
.btn:hover {
background-color:#ff3a00;
}
#homebtn{
top:0%;
}
#musicbtn{
top:7.5%;
}
#header a {
text-decoration:none;
color:#fff;
}
#soundcloud {
width:20%;
height:77.5%;
position:fixed;
left:0px;
top:15%;
}
#scfullscreen {
bottom:0px;
display:block;
position:fixed;
overflow: hidden;
white-space: nowrap;
height:7.5%;
left:0px;
width:20%;
}
#scfullscreen:hover {
background-color:#ff3a00;
}
.rotated {
transform: rotate(45deg);
-ms-transform: rotate(45deg); /* IE 9 */
-moz-transform: rotate(45deg); /* Firefox */
-webkit-transform: rotate(45deg); /* Safari and Chrome */
-o-transform: rotate(45deg); /* Opera */
}
@media screen and (max-width:768px) {
#header {
width:30%;
}
#soundcloud {
width:30%;
}
#scfullscreen {
width:30%;
left:0px;
}
}
非常感谢可以提供的任何帮助,因为我是 javascript 的新手,但我还没有在网上找到它的问题。
附注我的网站可以在这里找到,如果它更容易检查 http://l3mmydubz.onhub.online提前致谢,詹姆斯
最佳答案
问题出在你的if
语句测试表达式中:
if (!sccount%2 === 0) {
表达式 !sccount%2
被解释为好像它是这样括起来的:
if ( (!sccount) % 2 === 0)
当 sccount
为非零时,!sccount
将为 false
。反过来,false
将在 %
表达式中转换为 0
,因此答案始终为零,除非 sccount
为 0
。
如果您只想根据sccount
是偶数还是奇数在两个 Action 之间切换,您可以使用!==
来比较结果:
if ( sccount % 2 !== 0 )
关于javascript - 我有一个基于计数器的 if/else 语句,但由于某种原因,else 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34967651/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!