Use JavaScript to find a specific link

前端 未结 4 653
清歌不尽
清歌不尽 2021-01-20 03:54

Could anyone help me with a function for JavaScript which searches the source code and compares all of the links on the site with the specific link I am looking for.

4条回答
  •  囚心锁ツ
    2021-01-20 04:34

    You can use document.links to get the anchors, then just loop through grabbing the href, like this:

        var arr = [], l = document.links;
        for(var i=0; i

    See here.

    Then loop through the array to check for your specific link.

提交回复
热议问题