Edit in JSFiddle

$(function () {
    $("#b1").click(function () {
        console.log("b1");
        $("div input").css("backgroundColor", "blue");
    });
    $("#b2").click(function () {
        $("div>input").css("backgroundColor", "red");
    });
    $("#b3").click(function () {
        $("label+input").css("backgroundColor", "yellow");
    });
    $("#b4").click(function () {
        $("label~input").css("backgroundColor", "black");
    });
});
<input type="button" id="b1" value="E F" />
<input type="button" id="b2" value="E>F" />
<input type="button" id="b3" value="E+F" />
<input type="button" id="b4" value="E~F" />
<div>
    <label>1</label>
    <span>
        <input name="a1" />
    </span>
    <input name="a2" />
    <input name="a3" />
</div>
<div>
    <label>2</label>
    <input name="b1" />
    <span>
        <input name="b2" />
    </span>
    <input name="b3" />
</div>
<div>
    <label>3</label>
    <input name="c1" />
    <input name="c2" /> 
    <span>
        <input name="c3" />
    </span>
</div>