How to determine whether the jquery selector has obtained the element object

created at 08-26-2021 views: 2

To know whether a jquery selector has found/obtained an element object, we can assign the query result to a variable and judge the length of this variable:

it the length >0, then it means we've got at least one element:

var elements = $(".myclass");
    alert("not found");
created at:08-26-2021
edited at: 08-26-2021: