Set the value to ID of the element on click event by jquery
<p>I want to set the menu to active when click on it. This is what I've tried : </p>

<pre><code>&lt;script language="javascript" type="text/javascript"&gt;
  var select;
  $(document).ready(function () {
    $.getJSON(url, function (data) {
     $.each(data, function (index, dataOption) {

      var new_li = $("&lt;li class='level1' id='select_list'&gt;&lt;a href='javascript:void(0);' id='" + dataOption.ID + "' class ='selectedcategory'&gt;"  + dataOption.Name + "&lt;/a&gt;");

      $('a#' + dataOption.ID).click(function () {
        select = "selected";
        $('.level1').attr("id",select);
      });
     });
    });
  });
&lt;/script&gt;
</code></pre>

<p>What I tried to do is to set the id of 'level1' to selected, when I click on that link. But my coding is set all the link to selected, even I click only 1 link.</p>

<p>Could anyone give me the solution please.</p>

<p>Thanks so much.</p>
