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...
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);
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.
You can return out of the function:
if (data == 'false') {
return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With