JavaScript Next element with class next element with class javascript,next element with class jquery,

I want to find the next element with a given class after the element which trigged the event, regardless of the position of the searched element. Let’s say I have multiple pairs of inputs. One with the class „dynamic“ and the other one with the class „fit“.

Regardless of what’s inbetween the two inputs I want to copy the value of .dynamic and past it into the next input with the class .fit .

I tried multiple things and came the closest with going back to the parent element and find the input with the class „.fit“ – but as soon as there are multiple pairs of inputs within the same parent this does not work anymore. Any ideas how to solve that problem?

$('.dynamic').each(function() {
  var value = $(this).val();
  $(this).parent().find("input.fit").val(value);

});
* {
  font-family: "Arial";
  font-size: 11px;
  border: 0;
}

.wrapper {
  font-size: 0;
}

input {
  background-color: blue;
  margin: 0;
}

.fit {
  background-color: red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div class="wrapper">

  <input type="text" class="dynamic" value="Value 1 " />
  <input type="text" class="fit" value="-----" />

  <br>

  <input type="text" class="dynamic" value="Value 2" />
  <div>Something random here</div>
  <input type="text" class="fit" value="-----" />

</div>
Answer:1

How can I highlight selected value from a multiple html select tag with data from the database? <select required name="PrevOptns" id="PrevOptns" size="7" multiple class="select_with_label_wide"&...

How can I highlight selected value from a multiple html select tag with data from the database? <select required name="PrevOptns" id="PrevOptns" size="7" multiple class="select_with_label_wide"&...

  1. html highlight value

I have a large object, and not each element within the object has the same keys or number of keys. The first element has all the keys, and this first element's values are what I want to actually USE ...

I have a large object, and not each element within the object has the same keys or number of keys. The first element has all the keys, and this first element's values are what I want to actually USE ...

  1. javascript write object to file
  2. javascript write object to console
  3. javascript write object to json file
  4. javascript write object as string
  5. javascript write object to html
  6. javascript write object to csv
  7. javascript write object to localstorage
  8. javascript write object to json
  9. javascript write object
  10. javascript write object properties
  11. javascript write object to cookie
  12. javascript write object to document
  13. javascript write all object properties
  14. javascript write out object
  15. javascript write json object as string
  16. javascript write json object to console
  17. node write javascript object to file
  18. javascript write out json object
  19. javascript write into object

I am currently struggling copying the innerHTML part of classes to another div. The problem is that I am using the same class name for every div but each div has another content. I want to achieve ...

I am currently struggling copying the innerHTML part of classes to another div. The problem is that I am using the same class name for every div but each div has another content. I want to achieve ...

I need some help with RegEx, it may be a basic stuff but I cannot find a correct way how to do it. Please help! So, here's my question: I have a list of URLs, that are invalid because of double ...

I need some help with RegEx, it may be a basic stuff but I cannot find a correct way how to do it. Please help! So, here's my question: I have a list of URLs, that are invalid because of double ...