gpt4 book ai didi

jquery - 我试图在我的站点中实现 animate.css,它只适用于 jQuery 的 ready(load) 事件,它不适用于其他鼠标事件?

转载 作者:行者123 更新时间:2023-11-28 06:00:51 33 4
gpt4 key购买 nike

$('#div').ready(function () {
$('#div').addClass('animated bounceInLeft');
});

上面的代码运行良好。

但它不适用于以下代码。

 $('#TextBox1').on('click', function () {  
$('#TextBox1').addClass('animated shake');
});

如何解决这个问题??

这是我的完整代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"     Inherits="_Default" %>

<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2" runat="server">
<title>Foundation | Welcome</title>
<link rel="stylesheet" href="css/foundation.css" />
<link rel="stylesheet" href="css/motion-ui.css" />
<link rel="stylesheet" href="css/style.css" />
<link href="script/motion-ui-starter/css/animate.css" rel="stylesheet" />


<link href="script/motion-ui-starter/css/motion-ui.css" rel="stylesheet" />

<link href="script/motion-ui-starter/css/foundation.css" rel="stylesheet" />
<link href="script/motion-ui-starter/css/style.css" rel="stylesheet" />
<script src="script/motion-ui-starter/js/vendor/modernizr.js"></script>

<style>
.animated {
animation-duration: 2s;
animation-delay: 0s;
animation-iteration-count: 1;
}

.flash {
animation-delay: 3s;
}

.auto-style1 {
width: 100%;
border: 2px solid #000066;
background-color: #cccccc;
}

.auto-style4 {
width: 513px;
height: 44px;
}

.auto-style7 {
height: 52px;
text-align: center;
color: #FFFFFF;
}

.auto-style9 {
height: 44px;
width: 1403px;
}

.auto-style10 {
height: 53px;
}
</style>
<script src="script/motion-ui-starter/js/script.js"></script>
<script src="script/motion-ui-starter/js/foundation.min.js"></script>
<script src="script/motion-ui-starter/js/vendor/jquery.js"></script>
<script src="script/motion-ui-starter/js/vendor/motion-ui.js"></script>

<script src="script/motion-ui-starter/css/Java.min.js"></script>
<script>
$('#div').ready(function () {
$('#div').addClass('animated bounceInLeft');

});

$('#TextBox1').on('click', function () {
$('#TextBox1').addClass('animated shake');

});
</script>
</head>
<body>

<form id="form1" runat="server">
<div style="position: absolute; top: 63px; left: 2px; width: 280px; height: 203px; bottom: 513px;" id="div">
<table class="auto-style1">
<tr>
<td class="auto-style7" colspan="2"><strong>Login Here</strong></td>
</tr>
<tr>
<td class="auto-style4">User ID</td>
<td class="auto-style9">
<asp:TextBox ID="TextBox1" runat="server" Height="43px" Style="margin-left: 15px" Width="194px" CssClass="animated flash"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style4">Password</td>
<td class="auto-style9">
<asp:TextBox ID="TextBox2" runat="server" Height="44px" Style="margin-left: 14px" Width="196px" CssClass="animated flash"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style10" colspan="2">
<asp:Button ID="Button2" runat="server" Height="36px" Text="LOGIN" Width="94px" />
&nbsp;</td>
</tr>
</table>
</div>
</form>
</body>
</html>

当我点击网页上的任何按钮时,网页会出现动画,如何停止这个动画?如何让过渡动画只播放一次?

最佳答案

应该是

<script>
$(document).ready(function () {
$('#div').addClass('animated bounceInLeft');
$('#TextBox1').on('click', function () {
$('#TextBox1').addClass('animated shake');
});
});
</script>

一旦 DOM 准备就绪,事件绑定(bind)应该可以正常工作(有保证)。

关于jquery - 我试图在我的站点中实现 animate.css,它只适用于 jQuery 的 ready(load) 事件,它不适用于其他鼠标事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36762960/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com