JSFiddle - React, Tailwind, and code Playground

HTML

<a href="http://example.com">Link 1</a>
<a href="http://example.com">Link 2</a>
<a href="http://yahoo.com">Link 3</a>
<a href="http://gmail.com">Link 4</a>
<a href="http://example.com">Link 5</a>
<br/><br/>
<input type="button" id="btn" style="cursor:pointer;" value="get links with href = example.com"/>
<br/><br/>
<div id="result"></div>

JavaScript

jQuery.fn.getElementsByHref = function(str){ return $('a[href*="' + str + '"]'); };

$(document).ready(function(){

    var $document = $(this);
    
    $('#btn').click(function(){
        elems = $document.getElementsByHref('example.com');
        $('#result').html(elems.text() + " have 'example.com' value in href attribute");
    });
    
});