I have a simple object created through JQuery:
var userSettings = {
firstName: "John",
lastName: "Smith",
username: "Jsmith"
};
The HTML is quite simple as well:
<p>First Name <span id="firstName"></span></p>
<p>Last Name <span id="lastName"></span></p>
<p>Username <span id="username"></span></p>
My question is, how do I write a simple function that will support adding more key/values to the object. For this example, the function would simply update the text of the corresponding span with the proper ID.
Additionally
Parts of the object will not necessarily going to be handled through .text - is there a way to filter/define what method to use based off of something defined in the object? For example adding in userColor: red would use .css rather than .text.
Edit: Updated Fiddle with Function