Louis Stephens
Louis Stephens

Reputation: 790

On form input focus, show div

I have a form with an input (#test). Does anyone know how to, when in focus, display another div (#tool-tip) with jQuery?

<form>
    <div id="tool-tip"></div>
    <input id="test" />
    <input type="submit">
</form>

Upvotes: 2

Views: 8713

Answers (1)

Andrew Whitaker
Andrew Whitaker

Reputation: 126042

$("#test").focusin(function() {
    $("#tool-tip").show();
}).focusout(function () {
    $("#tool-tip").hide();
});

Using .focusin() and its opposite, focusout()

Upvotes: 16

Related Questions