I want to create a form where the user clicks on the desired color and the script generates a random shade of that color.
I generate the rgb color using random . But I can't figure out how to make a color shade that is generated, and not a random color.
$(function() { $('#color').change(function() { var min = 0, max = 255; var rgbColor = 'rgb('+(Math.floor(Math.random() * (max - min)) + min)+','+(Math.floor(Math.random() * (max - min)) + min)+','+(Math.floor(Math.random() * (max - min)) + min)+')'; $('#shade').val(rgbColor).css('border-color', rgbColor); }); }); #shade {border: 2px solid #000;} <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <p>Выберите цвет: <select id="color"> <option style="display: none;">Выбрать цвет...</option> <option value="red">Красный</option> <option value="green">Зелёный</option> <option value="yellow">Жёлтый</option> <option value="blue">Синий</option> <option value="grey">Серый</option> </select> </p> <p> Оттенок: <input type="text" id="shade"> </p> How to make a shade?