'Assign each element’s value with a class from an object based on ID
If I have this object:
const person = {
"name": "john",
"address": "john’s home"
};
and this part of a form:
<input class="form-control john" id="name">
<input class="form-control john" id="address">
then how do I assign the value of each id with its associated value from the object?
Something like:
$(".john").each(function(){
$(id).val(person.id)
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
