我的页面中有这个 div;
<div class="workspace" id="workspace">
<div data-ng-repeat="node in controller.Nodes" on-last-repeat=on-last-repeat>
</div>
</div>
在我的 typescript 代码中,我有这个来检查是否有未设置的必填字段。
if ($('#workspace').find('.ng-invalid').length != 0)
这是行不通的。长度始终为 0。我也尝试了以下但没有成功:
if ($('#workspace').find('.has-error.form-control').length != 0)
if ($('#workspace').find('.invalid').length != 0)
有什么想法吗?
最佳答案
子元素没有class属性。您可以使用 has 属性选择器
:
if ($('#workspace').find('[data-ng-repeat]').length != 0)
关于javascript - jquery 发现没有获取无效元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34431194/