JSFiddle - React, Tailwind, and code Playground
HTML
<a href="www.google.com" id="1">selected</a>
<a href="www.facebook.com" id="2">select</a>
<a href="www.gmail.com" id="3">selected</a>
JavaScript
var inputs = document.getElementsByTagName('a');
for(var i = 0; i < inputs.length; i += 1) {
if (inputs[i].textContent == "selected")
{
alert(inputs[i].id);
}
}