on change same value of input type text but different id in jquery -


i create table looping rows has 3 column input type text 3 input fields, give 2 & 3 input field same value input field 1 check out if code correct?
demo: https://jsfiddle.net/ninay/cpk15a98/

 $('#thelist[' + counter +'].docdt').change(function() { for(i=1; i<counter; i++){   $('#thelist[' + +  '].startdt ,#thelist[' + + '].enddt').val($(this).val());               }}); 

why use dot . when setting element id?

  • id="thelist[' + counter +'].startdt"

#thelist[' + counter + '].docdt selector mean target html element have:

  • id thelist[' + counter + ']
  • class docdt

you must use character replace dot . ex: _

i suggest use class selector problem, class selector can setting change event without `.each' loop.

i had change demo pls check that! hope can you! https://jsfiddle.net/cpk15a98/6/


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -