CSS select elements with partial id

后端 未结 1 931
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 08:16

I have some elements generated with PHP and I would like to know if it is possible to select an element with an incomplete id, example:

相关标签:
1条回答
  • 2020-11-28 08:43

    Not with ID selectors since they require complete ID names, but with substring attribute selectors:

    div[id^="as_"]
    div[id^="bs_"]
    

    But since your elements have a class attribute anyway, why not add a common class to each group of elements and select by that class to make things simpler? You should be able to determine the grouping class using PHP as you do to generate the IDs.

    0 讨论(0)
提交回复
热议问题