SOURCE

console 命令行工具 X clear

                    
>
console
(function () {
    $(() => {
        $(document).on("click", "label[for]", e => {
            const selected = $(e.target).attr("for");
            if (document.getElementById(selected)) {
                return;
            }

            try {
                const jq = eval(`(function(e){ return e.${selected} })`)($(e.target));
                if (jq.length > 0) {
                    jq.eq(0).focus();
                }
            } catch (e) {

            }
            try {
                const jq = $(selected);
                if (jq.length > 0) {
                    jq.eq(0).focus();
                }
            } catch (e) {

            }
        });
    });
})();
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="">
	<title></title>
</head>
<body>
    <div>
        <div>
            &lt;label for="input1"&gt;点我&lt;/label&gt;<br/>
            &lt;input id="input1" type="text" name="name" value="" /&gt;
        </div>
        <label for="input1">点我</label>
        <input id="input1" type="text" name="name" value="" />
    </div>
    <hr />
    <div>
        <div>
            &lt;label for=".input2"&gt;点我&lt;/label&gt;<br/>
            &lt;input class="input2 type="text" name="name" value="" /&gt;
        </div>
        <label for=".input2">点我</label>
        <input class="input2" type="text" name="name" value="" />
    </div>
    <hr />
    <div>
        <div>
            &lt;label for="nextAll(':input:first')"&gt;点我&lt;/label&gt;<br/>
            &lt;span&gt;&lt;/span&gt;<br/>
            &lt;input type="text" name="name" value="" /&gt;
        </div>
        <label for="nextAll(':input:first')">点我</label>
        <span></span>
        <input type="text" name="name" value="" />
    </div>
</body>
</html>

本项目引用的自定义外部资源