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']")
精彩评论