JSFiddle - React, Tailwind, and code Playground

How to change other textboxes value based on any text change?

by Akram kamal

HTML

<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>

JavaScript

/*
https://forum.jquery.com/topic/how-to-change-other-textboxes-value-based-on-any-text-change#14737000006645311
*/

$(document).ready(function() {
  var value1 = "";
  $('div').each(function(index) {
    $(this).replaceWith('<input type="text" class=div><input type="checkbox" class=check><br/>')
  });
  $('.div').change(function() {
    value1 = $(this).val();
    console.log(value1);
    /* next two lines are not part of your request, but they make it better */
    $(".check").not($(this).next()).prop("checked", false)
    $(this).next().prop("checked", true)
  });
  $('.check').change(function() {
    if (this.checked) {
      console.log(value1);
      $(this).prev('input').val(value1);
    }

  })

});