开发者

Find image tags in JQuery that are NOT wrapped in certain HTML

开发者 https://www.devze.com 2023-02-04 10:14 出处:网络
So I had another question on here of how I could find all the validation images on the view using JQuery. This worked, but it turns out that when we update our fields on the page, we don\'t com开发者_

So I had another question on here of how I could find all the validation images on the view using JQuery. This worked, but it turns out that when we update our fields on the page, we don't com开发者_运维百科pletely remove the validation images, we wrap them in this:

<span style="display: none;" validationfor="ResetDayComponent.ResetBusinessDayConvention">
</span>

So instead of using this JQuery:

if ( $('img.validation').length ) // validation errors exist
{
    alert("errors");
    return;
}

How can I find ONLY the validation images that are actually user visible?

Thanks!


You can use the :visible selector.

if ( $('img.validation:visible').length ) // validation errors exist
{
    alert("errors");
    return;
}


$("img.validation:visible")

http://api.jquery.com/category/selectors/visibility-filter-selectors/

0

精彩评论

暂无评论...
验证码 换一张
取 消