JSFiddle - React, Tailwind, and code Playground

HTML

<a href="http://www.mysite.com/index/yy.jpg">Link to JPG image</a><BR>
<a href="http://www.mysite.com/index/zz.jpg">Link to JPG image</a><BR>
<a href="http://www.mysite.com/index/bb.pdf">Link to PDF file</a><BR>
<a href="http://www.mysite.com/index/aa.pdf">Link to PDF file</a><BR>
<a href="http://www.mysite.com/products/100.php" target="_blank">New Product: Widget 5000 - $15</a><BR>
<a href="http://www.mysite.com/products/200.php" target="_blank">New Product: Smidgen X-Large - $20.99</a><BR>

JavaScript

$('a').click(function(){  //assigns a click event to all links on the page
    event.preventDefault() //prevents the link from opening like normal
    url = $(this).attr('href') //jQuery allows to grab the url from the href of the link
    linktext = $(this).text() //jQuery allows to grab the url from the href of the link
    if(url.match(/pdf|jpg/i)) {
        alert('File Link clicked');
    } else {
        alert('Regular Link Clicked');
        alert("Product Name: " + linktext.match(/New Product:(.*) - (\$[0-9]*(\.[0-9]*)?)$/i)[1]); //Alerts the first matched item, which is the first parentheses group
        alert("Price: " +linktext.match(/New Product:(.*) - (\$[0-9]*(\.[0-9]*)?)$/i)[2]); //Alerts the second matched item, which is the second parentheses group
    }
   
})