Skip to content Skip to sidebar Skip to footer

Make Focusout Event Ignore Some Elements

In the code below if you click on and a 'red block' appears. If you focus out then the 'red block' disappears. How do I make it so that focusou

Solution 1:

You can put the focus on both #one and #two

$('#one,#two').focus(function () {
    $('#divRemove').show();
}).focusout(function () {
    $('#divRemove').hide();
});

DEMO

Update

You can't really focus a div unless you give it a custom index like this with tabindex="0"

<div id="divRemove" tabindex="0"

and then in jQuery do this

$('#one,#two,#divRemove').focus(function () {
    $('#divRemove').show();
}).focusout(function () {
    $('#divRemove').hide();
});

DEMO

Post a Comment for "Make Focusout Event Ignore Some Elements"