最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Find an element by not exact id - Stack Overflow

programmeradmin3浏览0评论

There is an element with id looking like the following:

some_id_123456_some_id_id_id

where 123456 is an arbitrary number which is unknown. How do I find this element by id?

There is an element with id looking like the following:

some_id_123456_some_id_id_id

where 123456 is an arbitrary number which is unknown. How do I find this element by id?

Share Improve this question asked Jun 30, 2014 at 12:36 IncertezaIncerteza 34.9k51 gold badges160 silver badges270 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 21

You can do this by bining the both attribute starts with and ends with selector,

$('[id^=some_id][id$=_some_id_id_id]')

You can use Jquery selectors for this:

Combine Attribute Ends With Selector and Attribute Starts With Selector selectors:

$('[id^=some_id][id$=_some_id_id_id]')
发布评论

评论列表(0)

  1. 暂无评论