Jquery detect whether the acquired object exists

$ ( "Name") If the page does not exist this element will get to an object, so use the time to determine if returns true.

Jquery determines whether the acquired object is to be used to obtain the length of the element is determined , or converted into a DOM object determination .

1.if($("#name").length>0){do something...}              2. if($("#name")[0]){do something...} 

Guess you like

Origin www.cnblogs.com/shangmao/p/11531074.html