Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery - stop script executing on if condition

How can I stop script executing when if condition is met? Is it possible to do it without else? For example:

if(data == 'false')
{
stop
}
rest of the function...
like image 348
Sasha Avatar asked Nov 30 '12 00:11

Sasha


People also ask

How do I stop a jQuery script?

The stop() method is an inbuilt method in jQuery which is used to stop the currently running animations for the selected element. Syntax: $(selector). stop(stopAll, goToEnd);

How do I stop a Javascript script?

Using return: In order to terminate a section of the script, a return statement can be included within that specific scope. In the presence of return: No output will be shown since the program is terminated on encounter.


1 Answers

You can return out of the function:

if (data == 'false') {
    return false;
}
like image 159
Blender Avatar answered Oct 02 '22 01:10

Blender