简体   繁体   English

当用户单击按钮时,我希望我的ID晃动

[英]I would like my id to shake when the user clicks a button

i would like my id to shake when a user clicks it, how can i achieve that? 我希望我的ID在用户单击时摇一摇,我该如何实现? I am a beginner in jquery and am currently finishing up php, I am going to study jquery next.example: https://twitter.com/signup 我是jquery的初学者,目前正在整理php,接下来我将学习jquery。例如: https ://twitter.com/signup

this is my html: 这是我的HTML:

<input id="sub" type="submit" value="Sign Up">

and this is my js: 这是我的js:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
    <script>
               $( document ).click(function() {
      $( "#sub" ).effect( "shake",{distance:100} );
    });
     </script>

also if i wanted to implement times and direction would i do this?: 另外,如果我想实现时间和方向,我会这样做吗:

    $( "#sub" ).effect( "shake",{direction:right},{distance:100},{times:6} );

JSBIN : http://jsbin.com/uGAMulOL/3/ JSBINhttp//jsbin.com/uGAMulOL/3/

Add the # for the sub id element and put right in quotes. 添加#为子id元素,并把right的报价。 Also the options should be fixed in the object literal. 选项也应固定在对象文字中。

$("#sub").click(function() {
    $(this).effect("shake",{direction:'right',distance:100,times:6000});
});

Try this out:- http://jsfiddle.net/adiioo7/kx8q8/2/ 试试看: -http : //jsfiddle.net/adiioo7/kx8q8/2/

Use #sub instead of document on click. 单击时使用#sub代替document

jQuery(function ($) {
    $("#sub").click(function () {
        $(this).effect("shake", {
            direction: 'right'
        }, {
            distance: 100
        }, {
            times: 6
        });
    });
});

暂无
暂无

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

相关问题 检测用户何时“点击”Facebook 点赞按钮 - Detect when user “clicks” the Facebook like button 想要一个按钮来更改颜色并在用户单击时更改文本 - Would like a button to change color and change text as a user clicks 我想停止浏览器请求,当用户点击 UI 中的任何按钮时,比如浏览器上的停止按钮 - I want to stop the browser request, when user clicks on any button from UI, like stop button on browser 当用户单击按钮时,如何创建空格线(如 br)? - How can I create a space line (like a br) when user clicks on button? 我想将数据追加到表格下方,并在用户单击产品ID字段时进行搜索 - I want to append my data below the table and search when user clicks in the product id field 当点击它时,rails会改变我的like按钮的背景: - rails change the background of my like button when clicks on it : 我希望我的程序能够检测到用户何时通过uiwebview(iphone)单击网站上的“提交”按钮 - I want my program to detect when the user clicks submit button on a website via uiwebview (iphone) 当用户单击按钮时,如何保存可重复使用的React组件? - How do i make my reusable react component saves when the user clicks button? Why does my like button return a Json object { liked: true } but doesn't work with my ajax call in Django when a user clicks the like button - Why does my like button return a Json object { liked: true } but doesn't work with my ajax call in Django when a user clicks the like button 用户单击扩展程序上的按钮时如何插入文本? - How to insert text when the user clicks a button on my extension?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM