Determining whether jQuery has not found any element
2014-09-11 05:54
323 查看
http://stackoverflow.com/questions/2877654/determining-whether-jquery-has-not-found-any-element
what you're looking for. (If it finds nothing, this will
You're getting an object returned from that alert because jQuery (almost) always returns the "jQuery object" when you use it, which is a wrapper for the elements jQuery's found that permits method chaining.
$('#idThatDoesnotexist').lengthis
what you're looking for. (If it finds nothing, this will
=== 0.) So your conditional statement should probably be:
if($('#id').length) { /* code if found */ } else { /* code if not found */ }
You're getting an object returned from that alert because jQuery (almost) always returns the "jQuery object" when you use it, which is a wrapper for the elements jQuery's found that permits method chaining.
相关文章推荐
- java 提示----This element has no attached source and the Javadoc could not be found in the attached Javadoc
- selenium+python自动化88-批量操作循环点击报错:Element not found in the cache - perhaps the page has changed since it was looked up
- Determining whether or not a polygon (2D) has its vertices ordered clockwise or counterclockwise
- Selenium Webdriver : Element not found in the cache - perhaps the page has changed since it
- Note: This element has no attached source and Javadoc could not be found in the attached Javadoc解决办法
- 解决webdriver(Element not found in the cache - perhaps the page has changed since it was looked up )
- Webdriver如何解决页面元素过期:org.openqa.selenium.StaleElementReferenceException: Element not found in the cache - perhaps the page has changed since it was looked up
- Note: This element has no attached Javadoc and the Javadoc could not be found in the attached source
- Determining whether or not a polygon (2D) has its vertices ordered clockwise or counterclockwise
- 【Android】提示Note: This element has no attached source and the Javadoc could not be found in the attac
- Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.
- This element neither has attached source nor attached Javadoc and hence no Javadoc could be found
- jQuery:get value of specified element using val not value method...
- 连接MySQL数据库时出现The dirver has not received any packets from the server
- Initial job has not accepted any resources;check your cluster All masters are unresponsive! Giving u
- This element neither has attached source nor attached Javadoc and hence no Javadoc could be found
- spark-summit 中出现Initial job has not accepted any resources; check your cluster UI to ensure that wor
- Error: Class 'SimplePasswordHasher' not found
- Spark WARN cluster.ClusterScheduler: Initial job has not accepted any resources;check your cluster
- C# 操作MongoDb 错误Element '_v' does not match any field or property of class XXX