Counting div elements based on id

前端 未结 2 1612
鱼传尺愫
鱼传尺愫 2021-01-29 05:02

I have a page similar to:

2条回答
  •  遥遥无期
    2021-01-29 05:31

    To expand on Boldewyn's comment, you can provide multiple classes delimited by spaces, and then work with those classes separately or in combination.

    This probably removes the need for the ids, but I've left them in just in case:


    And then with jQuery you can count just the desired items with:

    $j('#content>#boxes>.box.content.text').length
    

    (or perhaps just use '#boxes>.box.text' or whatever works for what you're trying to match)

提交回复
热议问题