Answer the question
In order to leave comments, you need to log in
How to pass text from div to value?
Oddly enough, this question is not even on the Internet.
There are divs with class "name" and input with id:nama
How to pass text from div to value "value"?
In the block, the text is substituted only when the page is loaded using php, but in the input it can be conditionally passed only using jQuery.
I understand that the question is in one line of code, but somehow I can’t “make friends” with this question myself
Answer the question
In order to leave comments, you need to log in
return (sum + item.weight, 0);
You had an error in reduce, because of this, 0 was always returned. The start value must be passed after the callback function. This is first.
This condition matches filter
const arrayWeight = myArray.filter(item => item.type !== 'car').reduce((sum, item) => {
return sum + item.weight
}, 0);
I would give the div an id instead of a class.
var text = $('#div').text();
$('#input').val(text);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question