Jump to content
DarkxPunk

How to lose :focus

Recommended Posts

I can't seem to figure out how to make an element lose focus when clicking away from an element. Maybe this can't be done in CSS as my massive searching has given me very little.

 

Thanks for any ideas.

Share this post


Link to post
Share on other sites

Can you show an example? By default, a focusable element will lose focus when you've clicked off of it.

 

if you wanted to force the behavior with JavaScript you could do something like what I have here: http://jsfiddle.net/RDay/DWa6Q/2/

Edited by Day

Share this post


Link to post
Share on other sites

I have been using a CSS trick to make divs focus-able by adding tabindex="-1". But when you click away from the div it stays focused.

Share this post


Link to post
Share on other sites

I'm still seeing the same default behavior of losing focus when i click away from a div with a tabindex. If you have an example I can try to troubleshoot it for you.

 

Just for good measure though, here is the forced behavior with JavaScript for divs with tabindexes: http://jsfiddle.net/RDay/DWa6Q/4/

Edited by Day

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×