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)
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 4 days ago.
Improve this question
I wanted to add the same button at the end of all my posts (Wordpress site), so I added this code which worked perfectly:
add_action('x_before_the_content_end', function() {
if(is_singular( 'post' ) ) {
echo do_shortcode('[button type=”transparent” shape=”rounded” size=”jumbo” href=https://miracle-z.com/category/blogue-miracle-z/ title=Continuer]Continuer la lecture[/button]');
}
});
Then I tried to add another condition, so it would apply only to French pages.
So I added this:
add_action('x_before_the_content_end', function() {
if(ICL_LANGUAGE_CODE=='fr_FR' || is_singular( 'post' ) ) {
echo do_shortcode('[button type=”transparent” shape=”rounded” size=”jumbo” href=https://miracle-z.com/category/blogue-miracle-z/ title=Continuer]Continuer la lecture[/button]');
}
});
...but the button appears in all languages in all my posts...
What am I doing wrong?
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');
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 5 years ago.
Improve this question
I'm trying to get the console to read "No goal!" but every time I run it, I get "Goal". I'm guessing there's some basic syntax error that I'm making?
let isSoccerFan = false;
if (isSoccerFan=true) {
console.log("Goal!");
} else{
console.log("No goal!")
}
Your code is not correct. Try this:
let isSoccerFan = false;
if (isSoccerFan) {
console.log('Goal!');
} else {
console.log('No goal!');
}
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 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".