what is the right way to set input fields and labels from the properties of the same object in jquery?
<p>I have an object with a bunch of properties. Some properties are to be displayed in input elements, some in labels.</p>

<p>So, my code looks like this:</p>

<pre><code>  var data = getMyData();
  var propNames = Object.keys(data);
  var i, propName, elem;
  for (i = 0; i &lt; propNames.length; ++i) {
    propName = propNames[i];
    elem = $("#" + propName);
    if (elem.is('input')) {
      elem.val(data[propName]);
    } else {
      elem.html(data[propName]);
    }
  }
</code></pre>

<p>Is it the right way to do it in jquery? Cause it looks kinda ugly...</p>

<p>Thanks.</p>
