I currently do this to check if an elements exists:
if ($(".element1").length > 0 || $(".element2").length > 0 {
...stuff...
}
Is there a better way to rewrite the same? I mean, ".length" the same as ".length > 0" ?
Thanks
I currently do this to check if an elements exists:
if ($(".element1").length > 0 || $(".element2").length > 0 {
...stuff...
}
Is there a better way to rewrite the same? I mean, ".length" the same as ".length > 0" ?
Thanks
if ($(".element1").is('*') || $(".element2").is('*')) {
...stuff...
}
EDIT (per comment) Select elements by multiple classes in one call:
if ($(".element1, .element2").is('*') {
...stuff...
}