qq_40805263
2018-10-13 08:44js为什么点击图片,图片切换不了
<body>
<div></div>
<script>
var div=document.getElementsByTagName('div')[0];
div.style.backgroundColor="green";
div.style.height="100px";
div.style.width="100px";
var count=true;
div.onclick=function(){
if(count=true){
this.style.backgroundColor="red";
this.style.width="200px";
this.style.height="200px";
this.style.borderRadius="50%";
count=false;
}
if(count=false)
{
this.style.backgroundColor="green";
this.style.height="100px";
this.style.width="100px";
count=true;
}
}
</script>
</body>
我点击了一下图片,用控制台查看时,count的值确实由true转为false了,但是为什么再点时图片切换不了,不懂哪里错了。
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- dcalendar日历插件切换月份,绑定的点击事件失效,求大佬解决!
- javascript
- jquery
- 1个回答
- vue中定时器为什么没有停止?
- vue.js
- javascript
- 2个回答
- 看图片,怎么可以在点击+/-的时候,只改变点击的那个的input的值
- vue.js
- 2个回答
- 关于jquery多个标签类名的切换.....
- html5
- javascript
- css3
- 2个回答
- js里制作小标签切换碰到的问题 大神看一下
- javascript
- 1个回答
换一换