Diferència entre revisions de la pàgina «Sol mario animate hover»
De wikiserver
Línia 7: | Línia 7: | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> | <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> | ||
<style> | <style> | ||
− | + | ||
img { | img { | ||
position: relative; | position: relative; | ||
top:50px; | top:50px; | ||
left:250px; | left:250px; | ||
− | + | ||
} | } | ||
− | + | ||
</style> | </style> | ||
− | + | ||
<script> | <script> | ||
− | + | ||
− | + | ||
$(document).ready(function() { | $(document).ready(function() { | ||
− | $( | + | $('img').hover(function() { |
− | + | ||
− | $( | + | $(this).animate({top: '-=50px'}, 500); |
}, | }, | ||
function() { | function() { | ||
− | $( | + | $(this).animate({top: '+=50px'}, 500); |
} | } | ||
); | ); | ||
}); | }); | ||
− | + | ||
</script> | </script> | ||
</head> | </head> | ||
Línia 37: | Línia 37: | ||
</body> | </body> | ||
</html> | </html> | ||
− | |||
</source> | </source> |
Revisió de 13:09, 1 abr 2016
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<style>
img {
position: relative;
top:50px;
left:250px;
}
</style>
<script>
$(document).ready(function() {
$('img').hover(function() {
$(this).animate({top: '-=50px'}, 500);
},
function() {
$(this).animate({top: '+=50px'}, 500);
}
);
});
</script>
</head>
<body>
<img src="http://i1061.photobucket.com/albums/t480/ericqweinstein/mario.jpg"/>
</body>
</html>