JQuery中文本语法的抖动效应

Shake effect on text syntax in JQuery

本文关键字:抖动 语法 中文 文本 JQuery      更新时间:2023-09-26

当验证失败时,我试图对我的输入类型文本施加抖动效果。它提供了抖动效果,但我不知道如何更改方向、距离和时间的默认值。此外,我认为我在变量a中存储文本框的值时出错了。请告诉我正确的语法。非常感谢。

<!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>

有什么类似的选项吗??

 $("#button").click(function(){
         $(".target").effect( "shake", 
          {times:4}, 1000 );
      });

这是充分解释的抖动效应

这样就可以了。

$("#userNameTxt").effect('shake', { 
times: 10,
duration: 1000,
direction: 'left' // 'right' for right
});