jQuery - check if an element exists
By [)ia6l0 iii
Use the length property of an element to determine if it exists
If my div is named "mydiv", then the following if block checks if it exists
if ($("#mydiv").length)
{
//mydiv exists
}
Related FAQs
There are couple of ways to check if jQuery is loaded on a page.
A Pseudo class is a class that applies to an element due to the result of an user's action; Hover for example.
A Rule set in css refers to a selector and its declarations.
A Selector in CSS define or select the html elements that the CSS rules apply for.
Below is a short list of the advantages of using Inline Styles
Below is a short list of disadvantages of using inline styles
jQuery - check if an element exists (1200 Views)