Home  >  Q&A  >  body text

javascript - How to achieve accurate matching of Jquary's contains

$("span:contains(" pageNum ")").addClass("current")
pageNum is the subscript of the page, but if pageNum is 1, then 10, 11, and 12 will all execute addClass. Is there any good way to do this? Achieve accurate matching?

typechotypecho2687 days ago866

reply all(3)I'll reply

  • 高洛峰

    高洛峰2017-07-05 10:42:51

    修改

    reply
    0
  • 大家讲道理

    大家讲道理2017-07-05 10:42:51

    When rendering the subscript, add the index to the span's class. When retrieving, get the index through the current page number, and then add the class to the span corresponding to the index.

    reply
    0
  • 巴扎黑

    巴扎黑2017-07-05 10:42:51

    Just use this

    reply
    0
  • Cancelreply