So I have an .aspx view that dynamically adds validation images to the page at runtime using some built in validation we added into the models. When you look at the code for the view, you can't see all of the image tags (which are instead generated on the fly). However, I would like a way to know whether or not any of these specific image tags are contained in the HTML that the user sees. Basically I want to know if the page has passed validation or not.
The image tag is this (found using the pointer tool of firebug, similar to Developer Tools in IE):
<img src="/Extranet/img/exclamation.gif" class="validation">
What would be a way of finding out if any of these images are on the current HTML page that the user sees (remember this can change when certain fields are upda开发者_运维百科ted), in JQuery, to know when the user has gotten rid of them all and therefore passed validation.
Thanks!
if( $('.validation').length > 0 )
{
//images exist
}
This will check if there are any items with class validation
on the page. To limit to just image checking, use img.validation
.
if ( $('img.validation').length ) {
//images exist
}
精彩评论