Create the global variable in jquery
<p>I tried to get the value of the id of my list using this code :</p>

<pre><code>var ticket = '';
$(".selectedcategory").mouseover(function () {
   ticket = this.id;
});
$("#subCat").remove();
var urlCat = '&lt;%: Url.Content("~/") %&gt;' + "Gallery/TestGallery";
var list = $(".level1").append('&lt;ul &gt;&lt;/ul&gt;').find('ul');

$.getJSON(urlCat, { Depid: ticket }, function (dataCat) {
  $.each(dataCat, function (indexCat, dataOptionCat) {
      list.append('&lt;li&gt;&lt;a href="teste"&gt;' + dataOptionCat.Name + '&lt;/a&gt;&lt;/li&gt;');
});
});
</code></pre>

<p>I want to get the id of the ".selectedcategory" is "ticket" to use in "<code>$.getJSON(urlCat, { Depid: ticket }, function (dataCat) {</code>"  , but it is undefined when using outside the <code>mouseover()</code> function.</p>

<p>Could anyone tell me how to get this.id outside the <code>mouseover()</code> function please?</p>

<p>Thanks so much.</p>
