Jquery: Uncaught SyntaxError: missing ) after argument list [closed] - javascript

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am not sure what causes this problem (thought I covered it correctly). What happens is that on click, it should apply the grow class (which is 0.8 seconds) and after that flip over. Else it reverses this proces.
$('.click').toggle(function(){
var self = this;
$(this).removeClass('normal');
$(this).addClass('grow');
setTimeout(function(){
$(self).addClass('flip')
}800); <-- getting my error here
},
function(){
$(this).removeClass('flip');
setTimeout(function(){
$(this).addClass('normal');
$(this).removeClass('grow');
}800);
});
Yet I get an error Uncaught SyntaxError: missing ) after argument list on the first setTimeout (and probably ont he second one) but I dont see why i missed a )

You are missing the , before the timeout amount.
setTimeout(function(){
$(self).addClass('flip')
}800);
should be
setTimeout(function(){
$(self).addClass('flip')
},800);

Related

How do I define a state jquery/javascript? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
$(document).on("click", '.gifyImage', function(event) {
var clickedImage = $(event.target);
if(clickedImage.data('state') === "animate") {
//set to still
clickedImage.data('state', "still");
// update state clickedImage.data('state', 'animate');
clickedImage.data('state', "animate");
} else {
//set to animate
clickedImage.data('state', "animate");
//update state to still
clickedImage.data('state', "still");
}
clickedImage.attr('src', clickedImage.data('still'));
console.log(event.target);
})
gifImage.data(state, 'animate');
^^^ that is the so called error i'm getting when i open up my dev tools
Backstory to why i'm writing this function.. I have a assignment that requires me to have the gif image still and when clicked on the gif it will start to play (animate), and when i click it again it will go back to being still. This code here is giving me a error : "State is not defined"
the error im getting
In this line
gifImage.data(state, 'animate');
put state into quotes:
gifImage.data('state', 'animate');

If and else statement in Javascript is not working [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
want to run this javascript when there the button is clicked, if errors on the form check if statement and stop, if no errors execute the else statement......
$(document).ready(function () {
$('#continueToAttachments').on('click', function() { //on click button
if ($("#cevent").valid() = false) { // if errors stop the user from moving forward
return;
} else { // expecting this to run if there are no errors in the form
$('#Event-Information').removeClass('w--tab-active');
$('#Attachments').addClass('w--tab-active');
$('#Event-Information-Tab').removeClass('w--current');
$('#Attachments-Tab').addClass('w--current');
}
});
});
To check if a value is equal another you should use == or === to check if the variables are the same type too. = is for attribution.
if ($("#cevent").valid() == false)

JavaScript giving nonsense errors [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
So, me and a few friends are making a text adventure in JavaScript. in it, there is a possibility of the player using a heal spell, which runs the following code:
function heal() {
alert('You chant some ominous-sounding words, and your wounds heal');
alert('Hit points restored!');
hitPoints += 60;
blobsOfDoom -= 30;
burn();
MonsAtt();
Choose Spell();
}
Error Messages:
Firefox:
/*
Exception: SyntaxError: missing ; before statement
#Scratchpad/1:2703
*/
Chrome:
SyntaxError: Unexpected identifier.
Why is this error showing up? How do I fix it?
You cant have spaces in functions
Choose Spell();
Check your function declaration for ChooseSpell and any other occurances, and change them to a valid function name, like chooseSpell()

Uncaught SyntaxError: missing ) after argument list [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
Can't figure out what I'm doing wrong... here is my jquery code
<script>
$("#validationForm").submit(function(event) {
alert('test');
};
</script>
$("#validationForm").submit(function(event) {
alert('test');
};
^
Should be:
$("#validationForm").submit(function(event) {
alert('test');
});
If you see this error in your browser's Dev Tools, try clicking in its line, like: Syntax Error: Uncaught SyntaxError: missing ) after argument list file.js:1. When 1 is the line. It will show you where the error is.

$(...).offest is not a function [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am baffled to why I am experiencing this error, maybe its a bug with Jquery or maybe I'm blind, but Jquery has loaded and I can access the offset function after selecting an element?
Uncaught TypeError: $(...).offest is not a function
According to w3, I've used the function correctly.
Current code
var off = $("#canvas").offest();
var xPos = off.left + ( jqo.outerWidth(true)/2 );
var yPos = off.top + ( jqo.outerHeight(true)/2 );
console.log(yPos, xPos);
You have typo. Use offset instead of offest:
var off = $("#canvas").offset();

Categories