JS project 3 - RGB to Hex Converter and Vice-versa

by Pranab Dey

HTML

<div class="cont">
  <div class="rgbToHex">
    <div class="rgb">R
      <input type="text" name="r" id="r" maxlength="3"> G
      <input type="text" name="g" id="g" maxlength="3"> B
      <input type="text" name="b" id="b" maxlength="3">
      <button onclick="rgbToHex();">Convert to Hex</button>
    </div>
    <div class="hex">
      Hex
      <input type="text" name="hex" id="hex" maxlength="7">
      <button>Convert to RGB</button>
    </div>
  </div>
  <div class="result">Result : </div>
</div>

CSS

.rgb,.hex{
  margin-bottom: 10px;
  padding: 5px 2px;
}
input{
  border: 0;
  border-bottom: 1px solid;
  text-align: center;
}
input:focus{
  outline: 0;
}
.rgb input{
  width: 50px;
}
.hex input{
  width: 70px;
}

JavaScript

var r = document.querySelector("#r"),
g = document.querySelector("#g"),
b = document.querySelector("#b"),
hex = document.querySelector("#hex"),
btn = document.querySelectorAll("button");

function rgbToHex(){
	window.open("https://google.com");
}