<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="javascript.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-4">
</div>
<div class="col-sm-4 text-center">
<button type="button" onclick="color()" class="btn btn-default">Click me!</button>
</div>
<div class="col-sm-4">
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
var a = 125;
var b = 125;
var c = 125;
function color() {
if(a>=250) {
a = a - 10;
}
else if(a<=5) {
a = a + 10;
}
else {
a = a + Math.floor(Math.random() * 5);
}
if(b>=250) {
b = b - 10;
}
else if(b<=5) {
b = b + 10;
}
else {
b = b + Math.floor(Math.random() * 5);
}
if(c>=250) {
c = c - 10;
}
else if(c<=5) {
c = c + 10;
}
else {
c = c + Math.floor(Math.random() * 5);
}
document.getElementsByClassName("btn-default").style.backgroundColor = 'rgb(' + a + ',' + b + ',' + c + ')' + '!Important';
};
Button po prostu nie zmienia swoje koloru przy kliknięciu :| Bardzo proszę o pomoc