gpt4 book ai didi

jquery - 仅选择变量中的可见元素或任何其他属性元素

转载 作者:行者123 更新时间:2023-12-01 03:00:33 25 4
gpt4 key购买 nike

我的英语不太好,所以我会通过代码来解释这个问题。

function (jQelem1) {
jQelem1.[select_only_visible].each( function () { doSomething(); });
}

是否可以仅选择变量中的可见元素或任何属性其他元素。

谢谢。

最佳答案

jQuery:visible我们的选择器。

function (jQelem1) {
jQelem1.filter(':visible').each( function () { doSomething(); });
}

检查任何其他可见的属性

假设:

// check for presence of id
function (jQelem1) {
jQelem1.filter(':visible[id]').each( function () { doSomething(); });
}

// check for presence of class
function (jQelem1) {
jQelem1.filter(':visible[class]').each( function () { doSomething(); });
}

// check for both presence of id and class
function (jQelem1) {
jQelem1.filter(':visible[id][class]').each( function () { doSomething(); });
}

// check for both presence id = foo
function (jQelem1) {
jQelem1.filter(':visible[id="foo"]').each( function () { doSomething(); });
}

// check for both presence id = foo and class=bar
function (jQelem1) {
jQelem1.filter(':visible[id="foo"][class="bar"]').each( function () { doSomething(); });
}

还有更多。了解 jQuery selectors clearly

关于jquery - 仅选择变量中的可见元素或任何其他属性元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10844453/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com