jquery toggleClass() - access selected element
<p>I want to <a href="http://api.jquery.com/toggleClass/" rel="nofollow">toggle a class</a> based on some condition <strong>which I have to compute from the ID of the processed element</strong>:</p>

<pre><code>$(".centre li").toggleClass("highlight", someFunction(x));
</code></pre>

<p>(This will select about 10 list elements. I need each element's ID to look up if it requires highlighting or not.)</p>

<pre><code>someFunction(selectedElement) {
  if (selectedElement.id in someArray)
    return true
  else
    return false
}
</code></pre>

<p>I might have <strong>lost my way in closure-hell</strong>, but <code>this</code> in the function is set to another element. This is the real code:</p>

<pre><code>...
showListItem = function(linkSelector, listSelectors, contentSelector) {
return function() {
    $(".centre li").toggleClass("backgroundFullOrange", test(this));
    function test(a) {
        console.log($(a).attr("id")); // -&gt; id of the linkSelector-element
    }
}
};  
$(linkSelector).bind('click', showListItem(linkSelector, listSelectors, contentSelector))
...
</code></pre>

<p><strong>Update</strong>: turned out that toggleClass() was not the function I've been looking for. See accepted answer for correct usage.</p>
