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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...