JS Regex to find href of several a tags

后端 未结 9 1205
野性不改
野性不改 2020-12-28 08:04

I need a regex to find the contents of the hrefs from these a tags :

9条回答
  •  天命终不由人
    2020-12-28 08:51

    You may don't need Regex to do that.

    o = document.getElementsByTagName('a');
    urls = Array();
    for (i =0; i < o.length; i++){
       urls[i] = o[i].href;
    }
    

    If it is a plain text, you may insert it into a displayed non DOM element, i.e display: none, and then deal with it regularly in a way like I described.

提交回复
热议问题