Nazaret2005
Nazaret2005

Reputation: 373

Jquery advice and a decision

This is code

$('input:radio[name=game]').click(function () {
    $('input[type=button].a').removeClass('activ-now', true);
});

First i have input:radio[name=game] == 7/8/9 . Now i need do change the code to work like this

So when Up its ok, when Down do clear

*clear all = $('input[type=button].a').removeClass('activ-now', true);

here is all code

Thanks

Upvotes: -1

Views: 99

Answers (3)

jyrkim
jyrkim

Reputation: 2869

I hope I understood your question in the right way. Anyway my JSFiddle is here

I just added one variable prevGame that is used to make comparison

$(document).ready(function () {
    var prevGame;

and updated your radio button click event handler

  //When change game number, clear table numbers
    $('input:radio[name=game]').click(function () {
        var currentGame = parseInt($('input:radio[name=game]:checked').val());

        if (prevGame > currentGame) {
            $('input[type=button].a').removeClass('activ-now', true);
        }
        prevGame = currentGame;
    });

Upvotes: 1

Spokey
Spokey

Reputation: 10994

This is another option

$('input:radio[name=game]:checked').addClass('game-on');
$('input:radio[name=game]').click(function () {
    if(this.value < $('.game-on')[0].value)
        $('input[type=button].a').removeClass('activ-now', true);

    $('input:radio[name=game]').removeClass('game-on');
    $(this).addClass('game-on');    
});

Upvotes: 1

Arunkumar Vasudevan
Arunkumar Vasudevan

Reputation: 5330

I updated Fiddle check it

Fiddle

var Previous1=$(this).attr('id').split('game')[1];
    if(Previous<=Previous1)
    {      
    }
    else
    {
    $('input[type=button].a').removeClass('activ-now', true);
    }
  Previous=Previous1;

Upvotes: 1

Related Questions