gpt4 book ai didi

jquery - jQuery 中的 ^= 选择器有什么作用?

转载 作者:行者123 更新时间:2023-12-01 07:15:20 29 4
gpt4 key购买 nike

我在 JSfiddle 上阅读一些代码,发现了这段代码

 $('[name^="checkbox"]').change(function(event) {
if ($(this).is(":checked")) {
$(this).closest('tr').addClass('selected');
}
else {
$(this).closest('tr').removeClass('selected');
});

有人知道^=是什么意思吗?

最佳答案

检查此项

属性以选择器开始[name^="value"]

Selects elements that have the specified attribute with a value beginning exactly with a given string.

http://api.jquery.com/category/selectors/

To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id="foo.bar", can use the selector $("#foo\\.bar"). The W3C CSS specification contains the complete set of rules regarding valid CSS selectors. Also useful is the blog entry by Mathias Bynens on CSS character escape sequences for identifiers.

关于jquery - jQuery 中的 ^= 选择器有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19555970/

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