title: How to assign an explicit value to a tag attribute in jQuery.
body: <p>I am creating dynamic drop-downs and assigning ajax data to one of the items attribute of c:forEach loop.I got data in alert, but I am missing something while assign it to "items" tag.Please tell me what is wrong.</p>
  
  <p>HTML and jQuery code:</p>
  
  <pre><code>    &lt;select class="form-control" name="category" id="category"&gt;
        &lt;option value=""&gt;--Please select category--&lt;/option&gt;
        &lt;c:if test="${not empty productCategoryList}"&gt;
         &lt;c:forEach items="${productCategoryList}" var="productCategory"&gt;
          &lt;option id="catOptionId" value="${productCategory.pCatrgoryId}"&gt;${productCategory.pCategoryName}&lt;/option&gt;
         &lt;/c:forEach&gt;
        &lt;/c:if&gt;
      &lt;/select&gt;
  
  
      &lt;select class="form-control" name="subCategory" id="subCategory"&gt;
        &lt;c:if test="${not empty subCategoryList}"&gt;
         &lt;c:forEach items="${subCategoryList}" var="subProductCategory"&gt;
          &lt;option value="${subProductCategory.subCategoryId}"&gt;${subProductCategory.subCategoryName}&lt;/option&gt;
         &lt;/c:forEach&gt;
        &lt;/c:if&gt;
      &lt;/select&gt;
  
  &lt;script type="text/javascript"&gt;
        $(document).ready(function() {
        //Dropdown select
        $("#subCategory").attr("disabled", true);
        $("#category").change(function() {
          var catId = $(this[this.selectedIndex]).val();
          alert(catId);
          if (catId != "" &amp;&amp; catId != null) {
             $("#subCategory").attr("disabled", false);
             $.ajax({
              type : 'GET',
              url : 'getSubCatOnCat',
              data : {subCat : catId},
              success : function(data) {
                 alert(data);
              // Problem is at this point.
                 $("#subCategory c:forEach").attr("items",data);
              },
          error : function(xmlHttpRequest,textStatus,errorThrown) {
              if (xmlHttpRequest.readyState = 0 || xmlHttpRequest.status == 0)
              return;
          },
          });
          }
         });
       });
      &lt;/script&gt;
  </code></pre>