This article is mainly on the jquery to determine whether the existence of HTML elements of the two solutions are introduced, need friends can come to the reference, I hope to help you
In this case, the page part of the HTML element is controlled by the server-side language to display different content according to different circumstances, but on the same page in some cases when the DOM is ready to use AJAX and server communication, and some cases do not need, So I just want to be in the page when I specify the HTML tag to trigger the Ajax part, after all, this can reduce the burden on the server, a lot of nonsense, to the point: in fact, to solve the problem of jquery to determine whether the element exists, the method is simple: if ($ ("#abc" >0) {...} if ($ ("#abc"). html ()!= "") {...} There are two ways to determine whether an HTML document has the elements we want, and we tried using $ ("#abc")!= null/!$ ("#abc")/$.find ("#abc") ... The result is not, because regardless of whether the element exists will return object, then I temporarily use one of the above two methods to solve the problem, there is no better way to explore ...