1

I`m just using a If statement with the logical operator. I dont know why it is showing sytax error.

var divWidth = $("#columnwraper").width(); //getting the width of the div   
$("#right-button").click(function() {
    if (cursor != totalWidth && totalWidth !< divWidth) {
        $box2.animate({
            marginLeft : "-=300"
        }, "fast");

        cursor += 100;
    }
    // console.log(colwidth.width());
});

It`s showing that

[15:18:24.050] SyntaxError: missing ) after condition.

What am I doing wrong here?

4
  • 2
    What is !< operator? Why you don't use >= instead? Commented Jun 27, 2013 at 9:56
  • 3
    Note that != is one operator. It is not a combination of ! and ==. You cannot simply combine ! with other operators (i.e. !< is invalid). Commented Jun 27, 2013 at 9:58
  • @FelixKling Noted felix. Thank you. Commented Jun 27, 2013 at 10:04
  • No idea why this is being voted to close - this question is fine and has a valid accepted answer Commented Jun 27, 2013 at 12:34

3 Answers 3

8

Put it this way:

if (cursor != totalWidth && !(totalWidth < divWidth))

!< is not an operator.

Sign up to request clarification or add additional context in comments.

Comments

2

Error in totalWidth !< divWidth

Should be totalWidth < divWidth or totalWidth >= divWidth

1 Comment

Or >=. I think the ! is not just a typo.
1

Always put logical operators in inner brackets for operations like: (totalWidth < divWidth)

And !< is not an operator. You should use this:

 if ((cursor != totalWidth) && !(totalWidth < divWidth)) {... }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.