0

I tried jQuery code as follows. It showed nothing or had error message [object Undefined].

$("#rgbtxt").keyup(function() {
  var value = $(this).val(toString(16));
  $("#hextxt").text(value);
}).keyup();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="rgbhexcolorcode">
  <p id="rgb"></p>
  RGB <input id="rgbtxt" type="text" value="RGB code">
  <p id="hex"></p>
  HEXADECIMAL <input id="hextxt" type="text" value="HEXADECIMAL code">
</div>
Rory McCrossan
  • 319,460
  • 37
  • 290
  • 318
mehrad
  • 1
  • 1
  • You need to call `toString(16)` on an integer value, so you need to convert it first: `var value = parseInt($(this).val(), 10).toString(16);`. Also you need to set `val(value)` not `text()` – Rory McCrossan Sep 20 '21 at 08:33

0 Answers0