[HTML5] Focus Management Using CSS, HTML, and JavaScript

Source: Internet
Author: User

Something important to consider when coding a Web application is managing the user ' s focus. For keyboard and Screens reader users, we must ensure their focus is not dropped as content are deleted or shown in New cont Exts. Skip links also provide a-on-the-users-get past a lot of content. In this lesson, you'll learn HTML, CSS and JavaScript techniques for focus management so can be applied to many Situatio Ns.

For example, you had a list of items, when you want to delete an item, and want auto Foucs on next item ' s Delete Butt On.

All the need to do are to find next item, and send focus onto it.

    $ ('. Btn-delete'). On ('click', function () {        $ (  This ). Parent (). remove ();        Listitems.find ('. Btn-delete'). First (). focus ();    });

Next thing if you want the items which is out of Foucs managmenet don't to has the outline when you nav around the page.

{    outline: 0;}

To build a skip links:it hidden by default and when we use Tab keyboard, It'll shows up.

  <ulclass= "Skip-links">    <Li><ahref= "#main">Main Content</a></Li>    <Li><ahref= "#footer">Global Footer</a></Li>  </ul>
 ul.skip-links  { List-style :  none ;  position :  absolute ;}  ul.skip-links a  { Background-color :  #fff ;  display :  block ;  left :  -999999px ;  padding :  1em ;     position :  absolute ; } Ul.skip-links a:focus  { left :  0 ; }

[HTML5] Focus Management Using CSS, HTML, and JavaScript

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.