var a= document.getElementsByTagName('a'); for (var i = 0, len = a.length; i < len; ++i) { if ( a[i].textContent.match ( /\bтест\b/ ) ){ a[i].click(); } }