scarhand
scarhand

Reputation: 4337

what is wrong with this jquery?

I cant seem to figure this out. Something within this jquery code is breaking my site:

    $('.menu li').click(function() {
        nextslide = $(this).attr('id').replace('m_', '');

        if ($('#m_till').hasClass('active'))
            currentslide = 'till';
        else if ($('#m_receipts').hasClass('active'))
            currentslide = 'receipts';
        else
            currentslide = 'support';   

        slide_right(currentslide, nextslide);
    }

When I remove this code, my site works fine. So it has to be something within this function that is causing the problem.

Upvotes: -1

Views: 116

Answers (3)

danniel
danniel

Reputation: 1751

$('.menu li').click(function() {
    nextslide = $(this).attr('id').replace('m_', '');

    if ($('#m_till').hasClass('active'))
        currentslide = 'till';
    else if ($('#m_receipts').hasClass('active'))
        currentslide = 'receipts';
    else
        currentslide = 'support';   

    slide_right(currentslide, nextslide);
}

//close it
);
//close it

Upvotes: 1

Zachary Scott
Zachary Scott

Reputation: 21172

The easiest thing to do to troubleshoot any javascript is to assign the parts to variables, then check out the variables.

var a = $('.menu li');
a.click();

and more examples:

var a = $(this);
var b = a.attr('id');
var c = b.replace('m_', '');

It's likely you are referencing something that doesn't exist, assuming your syntax is correct. Use Chrome developer tools or Firefox Firebug to break on that variable and check the value.

Upvotes: 0

Amin Eshaq
Amin Eshaq

Reputation: 4024

it looks like theres a ); missing at the end

$('.menu li').click(function() {
        nextslide = $(this).attr('id').replace('m_', '');

        if ($('#m_till').hasClass('active'))
            currentslide = 'till';
        else if ($('#m_receipts').hasClass('active'))
            currentslide = 'receipts';
        else
            currentslide = 'support';   

        slide_right(currentslide, nextslide);
    });

Upvotes: 10

Related Questions