[英]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/ JSBIN : http : //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});
});
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.