Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在页面上有几个元素。有些人有这样的名字ID component1,component2等等。
component1
component2
component如何使用 jquery获取所有这些元素(名称以 开头的元素)?
component
使用^选择器
^
var elements = $('[id^="component"]')
在 jQuery 选择器中使用通配符:
$('name^=component')