0

I have the following snippet of code. I want some code to run during the 'change' event when clicking on a "select" input field. If the value of the option selected is zero, I would like to abort and not execute the remaining code. Here is the snippet :

$select.on('change',function(){
                        var newYear = this.value;
                        if(this.value === 0){
                            studentDiv.hide();
                            //I would like to return from here,and not execute any remaining code..
                        }else{

So how do I "return" from the the spot where I put the comment ? Typing return; doesn't seem to do anything ...

1 Answer 1

1

I feel like there might be more to this question because you answered it in your comment.

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

2 Comments

That didn't work - I tried return and it executed the code after the if block anyway....
Then you are not executing the code you think you are executing. The value is probably a string instead of a number making your === false

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.