JSFiddle - React, Tailwind, and code Playground

by Timmy Willison

HTML

<a href="http://www.w3.org/TR/2011/WD-html5-20110405/association-of-controls-and-forms.html#attr-fae-form">About attribute "form" of "input" in HTML5</a>
<form id="formid1">
    <input type="text" name="n" />
</form>

<form id="formid2">
    <input type="text" name="n2" form="formid1" />
    <input type="text" name="n2" form="formid3" />
</form>

<div id="result"></div>

JavaScript

var first = $('form input').eq(0).attr('form'); // non exists attr
var second = $('form input').eq(1).attr('form'); // attr with existing form
var third = $('form input').eq(2).attr('form'); // attr with non existing form
var anyattr = $('form input').eq(2).attr('sadf'); // non exists attr


console.log('first: %o\nsecond: %o\nthird: %o\nanyattr: %o', first, second, third, anyattr);

console.log('second form attached: %o', $('#' + second));
console.log('third form attached: %o', $('#' + third));