javascript - 为什么我的 fadeToggle 不适用于红色框?

标签 javascript jquery html css

当我点击按钮时,它支持淡入和淡出红色按钮,但它不支持,这是什么问题?

我的代码:

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  ${"button").click(function(){
  $("div").fadeToggle();
  });

});
</script>
</head>
<body>
 <button>Click Here To FadeToggle</button><br><br>
 <div style="width:80px;height:80px;background-color:red;"></div>
</body>
</html>

最佳答案

变化:

${"button")
 ^---------------

收件人:

$("button")
 ^---------------

$(document).ready(function(){
  $("button").click(function(){
  $("div").fadeToggle();
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<button>Click Here To FadeToggle</button><br><br>
<div style="width:80px;height:80px;background-color:red;"></div>

关于javascript - 为什么我的 fadeToggle 不适用于红色框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44753885/

相关文章:

CSS :before on inline SVG

javascript - @Input() 未定义,即使 @Input() 数据在屏幕上可见

javascript - 将 CSS 与 React/JSX 结合使用

javascript - "Could not find a declaration file for module"导入现有 .jsx 文件时

javascript - 如何通过NodeJs中的_id从MongoDB中的集合中删除许多文档

javascript - 最新产品上的 opencart jcarousel

javascript - Magnific Popup - 从第二个数组项开始画廊

javascript - 检测链接内点击了哪个单词

jquery - slider 中垂直居中字幕

html - 即使在隐藏侧边栏时,也使 div 子元素占据 div 父元素的 100%