mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-10-20 20:44:21 +00:00
45 lines
1.2 KiB
HTML
45 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>Animate Visual Test : Animate backgroundColor hex</title>
|
|
<link rel="stylesheet" href="../visual.css" type="text/css" />
|
|
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css">
|
|
<script type="text/javascript" src="../../../jquery-1.7.1.js"></script>
|
|
<script type="text/javascript" src="../../../ui/jquery.effects.core.js"></script>
|
|
<script type="text/javascript">
|
|
function hexFromRGB (r, g, b) {
|
|
var hex = [
|
|
r.toString(16),
|
|
g.toString(16),
|
|
b.toString(16)
|
|
];
|
|
$.each(hex, function (nr, val) {
|
|
if (val.length == 1) {
|
|
hex[nr] = '0' + val;
|
|
}
|
|
});
|
|
return hex.join('').toUpperCase();
|
|
}
|
|
function randomColorHex() {
|
|
return '#' + hexFromRGB(Math.floor(Math.random()*256), Math.floor(Math.random()*256), Math.floor(Math.random()*256));
|
|
}
|
|
$(function() {
|
|
$("#go").click(function() {
|
|
$("#animate-backgroundColor").stop().animate({ backgroundColor: randomColorHex() }, "fast");
|
|
});
|
|
})
|
|
</script>
|
|
<style type="text/css">
|
|
#animate-backgroundColor { width: 100px; height: 100px; background-color: gray; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="animate-backgroundColor"></div>
|
|
|
|
<button id="go">Go</button>
|
|
|
|
</body>
|
|
</html>
|