[英]bouncing image help code not worgking outside jsfiddle
I am trying to use this bit of jQuery in a web application. 我正在尝试在Web应用程序中使用这部分jQuery。 It seems to be working in jsfiddle, but not when implemented in my application. 它似乎在jsfiddle中工作,但是在我的应用程序中实现时却没有。 Here is my code: 这是我的代码:
$('.myimage').mouseenter(function() {
$(this).effect('bounce',500);
});
Here is my jsfiddle. 这是我的jsfiddle。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href= "style3.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
<script src="jquery.effects.bounce.js"></script>
</head>
<body>
<img class="myimage" src ="https://pbs.twimg.com/profile_images/3513354941 /24aaffa670e634a7da9a087bfa83abe6.png">
<script>
$(document).ready(function () {
$('.myimage').mouseenter(function () {
$(this).effect('bounce', 500);
});
});
</script>
</body>
</html>
Wrap you code in $(document).ready(function () { 将代码包装在$(document).ready(function(){
$(document).ready(function () {
$('.myimage').mouseenter(function () {
$(this).effect('bounce', 500);
});
});
asn don't forget to add jQuery library
file asn不要忘记添加jQuery library
文件
$(document).ready(function () {
$('.myimage').mouseenter(
function () {
$(this).effect('bounce', 500);
});
});
it needs to be in a document ready. 它需要准备好文档。
Also - just be weary that in your jsfiddle your image moves up another 30-40 px after a few times 另外-疲倦于在jsfiddle中,几次后图像会再移动30-40像素
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.