title: How can I retrieve value from data id?
body: <p>I have a selection with id <code>select id="accTypeSel"</code>. The option value is retrieved from the json file <code>jsonData.json</code>. What I want to do is, I want to display the branch selected in <code>div id="display"</code>. I had try it in below syntax but It's not working.</p>
  
  <pre><code>var $branchDetail=$('#accTypeSel option:selected').attr('data.accList-branch');
  var $value=$branchDetail.val();
  $('#display').html($value);
  </code></pre>
  
  <p>Selection from JSON.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;script src="js/jquery-1.7.1.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt; 
  &lt;body&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  Acc Type
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;select id="accTypeSel"&gt;&lt;/select&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      &lt;div id="display"&gt;&lt;/div&gt;
      &lt;script&gt;
          $.ajax({
              type:"GET",
              datatype:"json",
              async:true,
              url:'ref/jsonData.json',
              success:function(data){
                   for (var i=0;i&lt;data.accList.length;i++)
              {
                  var $option=$('&lt;option /&gt;');
                  $option.attr('value',data.accList[i].code,data.accList[i].branch);
                  $option.text(data.accList[i].code+" ("+data.accList[i].branch+")");
                  $('#accTypeSel').append($option);
              }
                  var $branchDetail=$('#accTypeSel option:selected').attr('data.accList-branch');
                  var $value=$branchDetail.val();
                  $('#display').html($value);
  
  
  
              }
          });
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>jsonData.json</p>
  
  <pre><code>{
      "accList":[
          {
              "code":"1234",
              "branch":"Branch1"
          },
          {
              "code":"4321",
              "branch":"Branch2"
          },
          {
              "code":"1111",
              "branch":"Branch3"
          }
      ]
  }
  </code></pre>