JSFiddle - React, Tailwind, and code Playground
HTML
<form id="foo">
</form>
<form id="login">
<a> forgot your password</a>
</form>
JavaScript
var theFormId = $('form').filter(function() {
return this.innerHTML.indexOf('forgot your password') != -1;
}).attr('id');
alert(theFormId);
var withContains= $('form:contains("forgot your password")').attr('id');
alert(withContains);