繁体   English   中英

jQuery函数在CodePen中起作用,但在Node.js Server中不起作用

[英]jQuery function works in CodePen but not in Node.js Server

jQuery CSS按钮过渡动画在CodePen中可完美工作,但是在Node.js服务器中使用相同的代码时,过渡将不起作用。

浏览器控制台不会引发任何错误。

链接到我的CodePen分支:

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更少文件:完全相同,从CodePen Link复制粘贴

从Node.js服务器运行时,除了单击登录按钮时的过渡之外,其他所有功能都可以正常工作。

Anyopne可以发现为什么还是jQuery中的错误吗?

尝试按钮type =“ button” ...对我有用

问题已解决。 包含jQuery的脚本标签需要放在form标签之后。 然后,一切正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM