sách gpt4 ai đã đi

Sự khác biệt giữa [property ~= value] và [property *= value] là gì?

In lại 作者:行者123 更新时间:2023-12-03 22:49:17 32 4
mua khóa gpt4 Nike

这两个 jQuery 选择器有什么区别?

以下是来自 w3schools.com 的定义:

  • [attribute~=value] 选择器选择带有特定属性,其值包含特定字符串。

  • [attribute*=value] 选择器选择带有特定属性,其值包含字符串。

làm mới:

以下是来自 jquery.com 的定义。这回答了我的问题:

  • [attribute~=value] - 选择具有指定属性且值包含给定单词(以空格分隔)的元素。

  • [attribute*=value] - 选择具有指定属性且值包含给定子字符串的元素。

1 Câu trả lời

*=Đúng attributeContains 选择器,来自 jquery docs :

Selects elements that have the specified attribute with a value containing a given substring.

~=Đúng attributeContainsWord 选择器,来自 jquery docs :

Selects elements that have the specified attribute with a value containing a given word, delimited by spaces.

Xem thêmattributeContains selector with Example of usage hereattributeContainsWord selector with example and usage here

attributeContains 选择器 用于属性值中包含的字符串,而attributeContainsWord 选择器 用于以分隔空格分隔的字符串。官方的jquery例子解释得很清楚。

minh họa:

属性包含选择器 [name*="value"]

HTML:





JQUERY:

$( "input[name*='man']" ).val( "has man in it!" );

Đầu ra:

nhập mô tả hình ảnh ở đây

演示示例:

Example of Attribute Contains Selector [name*="value"]

属性包含单词选择器[name~="value"]

HTML:





JQUERY:

$( "input[name~='man']" ).val( "mr. man is in it!" );

Đầu ra:

nhập mô tả hình ảnh ở đây

演示示例:

Example of Attribute Contains Word Selector [name~="value"]

关于jquery - [属性~=值] 和 [属性*=值] 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26305949/

32 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com