开发者

Using jquery, how can I select all the DIVs in my document with ID names containing specific text?

开发者 https://www.devze.com 2023-01-11 16:03 出处:网络
Using jquery, how can I select all the DI开发者_如何学JAVAVs in my document with ID names containing specific text?

Using jquery, how can I select all the DI开发者_如何学JAVAVs in my document with ID names containing specific text?

I want to select all the elements that contain 'parent', the problem is the string parent might be in the middle of the string.

I've been trying to use:

var allcontent_collection = $('div[id^=.*parent.*]')

It is not working. Should it or am I completely wrong in my approach?


You can do it using the attribute-contains (*=) selector instead, like this:

var allcontent_collection = $("div[id*='parent']")
0

精彩评论

暂无评论...
验证码 换一张
取 消