jquery找不到无效元素

Ger*_*les 5 javascript jquery twitter-bootstrap

我的页面里面有这个div;

<div class="workspace" id="workspace">
    <div data-ng-repeat="node in controller.Nodes" on-last-repeat=on-last-repeat>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

在我的打字稿代码上,我有这个来检查是否有必要的字段未设置.

if ($('#workspace').find('.ng-invalid').length != 0)
Run Code Online (Sandbox Code Playgroud)

这不起作用.长度总是0.我也尝试了以下但没有运气:

if ($('#workspace').find('.has-error.form-control').length != 0)
if ($('#workspace').find('.invalid').length != 0)
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Mil*_*war 0

子元素没有 class 属性。你可以使用has attribute selector

if ($('#workspace').find('[data-ng-repeat]').length != 0)
Run Code Online (Sandbox Code Playgroud)