这个带有方括号和插入符号的 jQuery 代码是什么意思



这个jQuery代码是什么意思?

$('tr[id^="message"]')

这意味着 - 选择id属性以字符串开头的所有tr元素message

http://api.jquery.com/attribute-starts-with-selector/

[]是指元素的属性(id是一个),id^是一个通配符,这意味着id必须以"message"开头。

它表示 id 以"message"开头的表行:

$('tr // a table row
[id //having an id 
^="message"]') // starting with 'message'

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

最新更新