Reputation: 237
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?
Upvotes: 1
Views: 1078
Reputation: 1193
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)) {... }
Upvotes: 1
Reputation: 40639
Error in totalWidth !< divWidth
Should be totalWidth < divWidth
or totalWidth >= divWidth
Upvotes: 2