jQuery - Find href that contains a value and return the full value

前端 未结 5 2123
被撕碎了的回忆
被撕碎了的回忆 2021-01-06 01:12

I\'d like to search the body for an href that contains /test/. I then want to return the entire href value e.g. /test/123/.

Below is what I

5条回答
  •  借酒劲吻你
    2021-01-06 01:42

    You can do it like following using jQuery contain attribute selector.

    $('a[href*="/test/"]').attr('href');
    

提交回复
热议问题