Javascript JQuery中文本语法的抖动效应
当验证失败时,我试图在输入类型文本上产生震动效果。它提供了震动效果,但我不知道如何更改方向、距离和时间的默认值。另外,我认为我在变量a中存储textbox的值时出错了。请告诉我正确的语法。多谢各位Javascript JQuery中文本语法的抖动效应,javascript,jquery,Javascript,Jquery,当验证失败时,我试图在输入类型文本上产生震动效果。它提供了震动效果,但我不知道如何更改方向、距离和时间的默认值。另外,我认为我在变量a中存储textbox的值时出错了。请告诉我正确的语法。多谢各位 <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(document).ready(function(){
$("#submitBtn").click(function(){
$a = $("#userNameTxt").value;
if ($a != "text")
{
$("#userNameTxt").effect("shake");
}
});
});
</script>
</head>
<body>
<form action="#" >
<input type="text" name="userNameTxt" id="userNameTxt" placeholder="username" />
<br/>
<input type="submit" value="submit" id="submitBtn" />
</form>
</body>
</html>
$(文档).ready(函数(){
$(“#submitBtn”)。单击(函数(){
$a=$(“#usernametx”).value;
如果($a!=“文本”)
{
$(“#userNameTxt”).effect(“shake”);
}
});
});
类似这些选项的东西
$("#button").click(function(){
$(".target").effect( "shake",
{times:4}, 1000 );
});
这里是这应该可以
$("#userNameTxt").effect('shake', {
times: 10,
duration: 1000,
direction: 'left' // 'right' for right
});
在这里发布之前,请务必阅读API文档。您将在那里获得所有详细信息。下面是一个示例。