元素属性值末端匹配选择器 [name$=”value”]| jqueryAPI 2.2 中文手册- AspRain.cn 致力于Web开发技术翻译整理
From jQuery API 2.2.0
元素属性值末端匹配选择器 [name$=”value”]
attributeEndsWith selector
描述:选择这样的元素:它们具有指定的元素属性,而且该元素属性的值严格以某个给定的字符串结束。该对比是大小写敏感的。
version added: 1.0
jQuery( "[attribute$='value']" )attribute: 一个元素属性名。
value: 一个元素属性值。可以是不用引号的单词,或者用引号括起的字符串。
示例
找到所有的带有一个元素属性名以“letter”结束的<input>并把它的值设置为一些文本。
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>attributeEndsWith demo</title> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> </head> <body> <input name="newsletter"> <input name="milkman"> <input name="jobletter"> <script> $( "input[name$='letter']" ).val( "a letter" ); </script> </body> </html>
演示结果
如果网页上不能运行示例,请点击http://www.asprain.cn/jQueryAPI/attribute-ends-with-selector.htm查看示例。
如果你觉得本文档对你有用,欢迎给翻译作者支付宝打赏,支持翻译作者源源不断翻译更多有用的技术文档。