Rasgele Rgb Renk Kodu Oluşturmak

by Ozgur Ozer

HTML

<input type="button" id="olustur" value="Oluştur">
<input type="text" id="renk">

JavaScript

function rasgeleRgbRenkKodu(){
    renk="rgb("+(Math.floor(Math.random()*256))+","+
    (Math.floor(Math.random()*256))+","+
    (Math.floor(Math.random()*256))+")";
    return renk;
}

$("#olustur").click(function(){
    $("#renk").val(rasgeleRgbRenkKodu());
    $("body").css("backgroundColor",rasgeleRgbRenkKodu());
});