Hey, I'm a little confused about a simple jQuery statement...
I want the operation to proceed only if A and B are true. If A isn't true, stop. If A and B are true, then continue.
Thanks!
Hey, I'm a little confused about a simple jQuery statement...
I want the operation to proceed only if A and B are true. If A isn't true, stop. If A and B are true, then continue.
Thanks!
jQuery is just a library which enhances the capabilities of the DOM within a web browser; the underlying language is JavaScript, which has, as you might hope to expect from a programming language, the ability to perform conditional logic, i.e.
if( condition ) {
// do something
}
Testing two conditions is straightforward, too:
if( A && B ) {
// do something
}
Dear God, I hope this isn't a troll...
You can wrap jQuery calls inside normal javascript. So, for example:
$(document).ready(function() {
if (someCondition && someOtherCondition) {
// make some jQuery call
}
});
To add to what the others are saying, A and B can be function calls as well that return boolean values. If A returns false then B would never be called.
if (A() && B()) {
// if A() returns false then B() is never called...
}
It depends on what you mean by stop. If it's in a function that can return void then:
if(a && b) {
// do something
}else{
// "stop"
return;
}