var text = <div id="mc_embed_signup">
<form action="https://groovepages1test.us20.list-manage.com/subscribe/post?u=ef1fb2fb5c60353bfdffd48db&id=71b534c03f" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<h2>Subscribe to our mailing list</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
<label for="mce-EMAIL">Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_ef1fb2fb5c60353bfdffd48db_71b534c03f" tabindex="-1" value=""></div>
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>
var results = [];
$("<form></form>").html(stext).find("input").each(function(l) {
results.push($(this).name);
});
console.log(results);
const inputs = $('input', str).get();
// или
const inputs = new DOMParser()
.parseFromString(str, 'text/html')
.querySelectorAll('input');
// или
const { elements: inputs } = document
.createRange()
.createContextualFragment(str)
.querySelector('form');
// или
const inputs =
(el => (el.innerHTML = str, el.getElementsByTagName('input')))
(document.createElement('div'));
const getName = el => el.name;
// или
const getName = el => el.getAttribute('name');
// или
const getName = el => el.attributes.name.value;
const names = Array.from(inputs, getName);
// или
const names = Array.prototype.map.call(inputs, getName);
// или
const names = [];
for (const n of inputs) {
names.push(getName(n));
}
// или
const names = [];
for (let i = 0; i < inputs.length; i++) {
names[i] = getName(inputs[i]);
}