Answer the question
In order to leave comments, you need to log in
How to write selected values from select to input if they (input and select) are dynamic?
Hello, clarification of the question: an unknown number of blocks are created in the loop (the number depends on the data in the database), each block has a select and an input, how to get this input in order to write the changing select values \u200b\u200bto it, is it impossible to identify it?
Answer the question
In order to leave comments, you need to log in
Something like this, for example:
$('select').on('change', function(){ // при событии change
var sel = $(this)
sel.closest('.block') // ищется ближайший родитель .block (обертка, объединяющая select и input)
.find('input') // в нем ищется инпут
.val(sel.val()) // и записывается значение
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question