How to select all elements whose ID starts and ends with specific strings?

前端 未结 1 1042
[愿得一人]
[愿得一人] 2020-12-03 07:16

In CSS, how can I select all elements where their id begins with section_ and ends with _dummy?

E.g. I

相关标签:
1条回答
  • 2020-12-03 07:36

    The following CSS3 selector will do the job:

    tr[id^="section_"][id$="_dummy"] {
        height: 200px;
    }
    

    The ^ denotes what the id should begin with.

    The $ denotes what the id should end with.


    id itself can be replaced with another attribute, such as href, when applied to (for example) <a>:

    a[href^="http://www.example.com/product_"][href$="/about"] {
        background-color: red;
    }
    
    0 讨论(0)
提交回复
热议问题