DarkxPunk Posted June 17, 2014 Share Posted June 17, 2014 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. Link to comment Share on other sites More sharing options...
es131245 Posted June 17, 2014 Share Posted June 17, 2014 JS can focus other element, but not CSS. Link to comment Share on other sites More sharing options...
Day Posted June 18, 2014 Share Posted June 18, 2014 (edited) 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 June 18, 2014 by Day Link to comment Share on other sites More sharing options...
DarkxPunk Posted June 18, 2014 Author Share Posted June 18, 2014 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. Link to comment Share on other sites More sharing options...
Day Posted June 18, 2014 Share Posted June 18, 2014 (edited) 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 June 18, 2014 by Day Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now