title: How to select the default selection on the item in my list box using jquery
body: <p>Using this code I am inserting the code into listbox.</p>
  
  <pre><code>&lt;select id="lstCodelist" size="17" name="lstCodelist" style="width:100%;height:280px;background-color:#EFEFFB;"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>Using this code I am displaying data in to lstCodelist box.</p>
  
  <pre><code>$.fn.fillSelectDD = function (data) {
      return this.clearSelectDD().each(function () {
          if (this.tagName == 'SELECT') {
              var dropdownList = this;
              $.each(data, function (index, optionData) {
                  var option = new Option(optionData.Text, optionData.Value);
  
                   if ($.browser.msie) {
                      dropdownList.add(option);
                  }
                  else {
                      dropdownList.add(option, null);
                  }
              });
          }
      });
  }
  </code></pre>
  
  <p>This is the function I am calling to insert into one list box to other list.</p>
  
  <pre><code>function DoInsert(ind) {
              var sourceIndex = $("#lstAvailableCode").val();
              var targetIndex = $("#lstCodelist").val();
              var success = 0;
              var rightSelectedIndex = $("#lstCodelist").get(0).selectedIndex;
              var functionName = "/Ajax/SaveCodeforInsert";
              if (ind == "plan") {
                  functionName = "/Ajax/SaveCodeforInsertForPlan";
              }
  
              $.ajax({
                  type: "POST",
                  traditional: true,
                  url: functionName,
                  async: false,
                  data: "ControlPlanNum=" + $("#ddControlPlan").val() + "&amp;LevelNum=" + $("#ddlLevel").val() + "&amp;ColumnNum=" + $("#ddlColumn").val() + "&amp;SourcbaObjectID=" + sourceIndex + "&amp;TargetbaObjectID=" + targetIndex + "&amp;userID=&lt;%=Model.userID%&gt;",
                  dataType: "json",
                  error: function (data) {
                      alert("Error Adding Code");
                      FinishAjaxLoading();
                  },
                  success: function (data) {
                      if (data == 0) { success = 1; } else { success = data; }
                      // $("#lstCodelist option").eq(1).attr('selected', 'selected')
                      $("#lstCodelist option:first-child").attr("selected", "selected");
                      FinishAjaxLoading();
                  }
              });
  </code></pre>
  
  <p>but using this code in my success function I am not able to select assign or hightlight or select to this lstCodelist box.</p>
  
  <pre><code>// $("#lstCodelist option").eq(1).attr('selected', 'selected')
                          $("#lstCodelist option:first-child").attr("selected", "selected");
  </code></pre>
  
  <p>but its not working in my code right now is that I am doing something wrong here?</p>
  
  <p>Thanks</p>