[jQuery] beginner variable problem

[jQuery] beginner variable problem


hi,
I'm encountering a problem with a variable in a toggle event.
see my example online here:
http://www.allnighters.net/jq-issue/
my js code:
$(document).ready(function(){
    $("#contests ul li span a").toggle(
        function(){
            var parag_count = $("#contests ul li span a").index(this);
            alert(parag_count);
            $("#contests ul li p:eq("+ parag_count +")").css("background",
"yellow");
            return false;
        },
        function(){
            $("#contests ul li p:eq("+ parag_count +")").css("background",
"none");
            return false;
        }
    );
});
and my html:
<div id="contests" style="width: 400px; margin-left: 20px;">
<ul>
<li class="uneven">
<span><a href="#">4x2 Karma Hotel Tickets</a></span>

Deze wedstrijd loopt af op 23 April om 23u.


</li>
<li class="even">
<span><a href="#">5x2 F*uck Lany... Here's Stephan
Bodzin</a></span>

Deze wedstrijd loopt af op 23 April om 23u.


</li>
...
</ul>
</div>
the problem is that I don't know how to pass the 'parag_count'
variable on to the 2nd function of the toggle event.
thanks in advance.







































    • Topic Participants

    • rb