title: Select a value after loading a dropdown list using javascript and json data
body: <p>I am trying to select the item which has the defaulttext in my dropdown list after loading all the json data, however it doesn't work. not sure what is wrong.</p>
  
  <pre><code>function populateSelect(json, element, defaulttext) {
  
          $(element).find('option').remove().end().attr('disabled', false).append($('&lt;option&gt;').text(defaulttext).attr('value', ''));
          $.each(json, function(i, value) {
              $(element).append($('&lt;option&gt;').text(value).attr('value', value));
          });
  
          element.options[defaulttext].selected = true; &lt;-- doesn't work
      }
  </code></pre>