所以,如果我有以下页面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Untitled</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/themes/base/jquery-ui.css" type="text/css">
<style>
#content {
height: 100px;
width: 100px;
background: #1E98DB;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
$('#content').click(function() {
var color = $(this).css('backgroundColor');
document.write(color);
});
});
</script>
</head>
<body>
<div id="content">
</div>
</body>
</html>
当我点击蓝色#content
<div>
时,<div>
将替换为:
rgb(30, 152, 219)
如何以十六进制形式提取确切颜色?
谢谢!