jQuery CSS 按钮过渡动画在 CodePen 中完美运行,但是当在 Node.js 服务器中使用相同的代码时,过渡效果不起作用。
浏览器控制台不会抛出任何错误。
链接到我的 CodePen 分支:
这是在服务器上运行的相同代码。 服务器 HTML 文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Login</title>
<link rel="stylesheet/less" type="text/css"
href="/css/login_styles.less" />
<script
src="https://cdnjs.cloudflare.com/ajax/libs/less.js/3.7.1/less.min.js"
></script> <script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/
jquery.min.js"></script>
<script>
$("#login-button").click(function(event){
event.preventDefault();
$('form').fadeOut(500);
$('.wrapper').addClass('form-success');
});
</script>
</head>
<body>
<div class="wrapper">
<div class="container">
<h1>Welcome</h1>
<form class="form">
<input type="text" placeholder="Username">
<input type="password" placeholder="Password">
<button type="submit" id="login-
button">Login</button>
</form>
</div>
<ul class="bg-bubbles">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>
服务器 CSS Less 文件: 完全从 CodePen 链接复制粘贴
从 Node.js 服务器运行时,除了单击登录按钮时的转换外,一切正常。
任何人都可以找出原因或者这是 jQuery 中的错误吗?
最佳答案
试试 button type="button"... 为我工作
关于javascript - jQuery 函数在 CodePen 中有效,但在 Node.js 服务器中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53184011/