problem with jquery each and swich between 2 things

Posted by moustafa on Stack Overflow See other posts from Stack Overflow or by moustafa
Published on 2010-03-13T10:13:28Z Indexed on 2010/03/13 10:15 UTC
Read the original article Hit count: 142

Filed under:

first see this post i got this code

$('.yesno').click(function(){
    $('.yesno').each(function(i, v){
        $(v).removeClass('selected');
    });
    $(this).addClass('selected');

     return false;
});

and html this

    <a href="#">
    <span  class="Yes yesno">Yes</span>
</a>

<a href="#">
    <span class="No yesno">No</span>

no the problem when i make more than one vote iam get very big problem

see this

<a href="#">
    <span  class="Yes yesno">Yes</span>
</a>

<a href="#">
    <span class="No yesno">No</span>
</a>
<a href="#">
    <span  class="Yes yesno">Yes</span>
</a>

<a href="#">
    <span class="No yesno">No</span>
</a>
</a>

when click first yes its choose the first yes and hwen iam going to the next yes when click its because selected but the first yes because unselected

i want make some thin make each yes and know is differant of others

© Stack Overflow or respective owner

Related posts about jQuery