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');
Related
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 2 years ago.
Improve this question
Hi im pretty sure what im about to post might not be enough info (if so please let me know what more is needed). I am using node js and having a really weird error. Below is the code and output.
if (currentPrice > variableData[i].stopLossHard) {
console.log('if')
console.log(currentPrice)
console.log('is more than')
console.log(variableData[i].stoplossHard)
}
Output:
if
92.7
is more than
93.62700000000001
This is consistently happening. I also made sure that both currentPrice and variableData[i].stopLossHard are numbers and not strings (I made sure in the code and in the output its the color of a number not a string)
Any ideas is highly appreciated.
The attribute you print is different than the one you check in the if statement:
(In the if stopLossHard has a capital L, stop-L-ossHard, what you print doesn't)
Try this:
if (currentPrice > variableData[i].stoplossHard) {
console.log('if')
console.log(currentPrice)
console.log('is more than')
console.log(variableData[i].stoplossHard)
}
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)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 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
I am struck with adding a onclick function to my span - though it looks simple - I am sure - there is something I am missing
Please find the code sample below
https://jsbin.com/naqejanigu/edit?html,css,js,output
function conv() {
var cel = document.getElementbyId('unit');
cel.innerHTML = 'F';
}
function conv() {
var cel = document.getElementById('unit');
cel.innerHTML = 'F';
}
getElementbyId should be getElementById.
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);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 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
I wanted to insert value in if condition and remove it in else condition.
$(document).ready(function(){
var ids=[];
$('input[type="checkbox"]').click(function(){
if($(this).prop('checked')){
var id = $(this).val();
ids.push(id)
}
else
{
//remove value from array
}
});
});
Instead of :
array.push(id)
It should be :
ids.push(id)
(because your array name is ids not array)
Click event's callback function parameter is event
$('input[type="checkbox"]').click(function(array){
"array" is instance of event on above code.
Then variable "array" cannot have function "push".