Detailed bootstrap Aria-label and Aria-labelledby application _javascript techniques

Source: Internet
Author: User
Tags button type

Aria-label

Normally, the input component of the form form has a corresponding label. When the input component gets the focus, the screen reader reads the text from the corresponding label.
Such as:

<! DOCTYPE html> 
 
 

But if we don't set the label for the input box, when it gets the focus, the screen reader reads out the value of the Aria-label property, and Aria-label does not visually render the effect.
Such as:

<body> 
 <form role = "form" > 
  <div class= "Form-group col-lg-3 form-horizontal" > 
   <div class= "Col-lg-7" > 
    <input type = "text" id = "Idcard" class= "form-control" Aria-label = "identity card number" > 
   </div >   
  </div>  
 </form> 

Aria-labelledby Property

When the desired label text already exists in another element, you can use Aria-labelledby and value it as the ID of all the read elements. As follows:
When the UL gets to the focus, the screen reader reads: "Choose your Position"

<body> 
 <div class= "dropdown" > 
  <button type= "button" class= "btn dropdown-toggle" id= " DropdownMenu1 " 
   data-toggle=" dropdown "> 
   Select your position 
   <span class=" caret "></span> 
  </ button> 
  <ul class= "Dropdown-menu" role= "menu" aria-labelledby= "dropdownMenu1" > 
   <li role= " Presentation "> 
    <a role=" MenuItem "tabindex="-1 "href=" # "> Test Engineer </a> 
   </li> 
   < Li role= "presentation" > 
    <a role= "MenuItem" tabindex= "-1" href= "#" > Development Engineer </a> 
   </li> 
   <li role= "Presentation" > 
    <a role= "MenuItem" tabindex= "-1" href= "#" > Sales Engineer </a> 
   </li>   
  </ul> 
 </div> 

PS: If an element has Aria-labelledby and Aria-label at the same time, the read-screen software will first read out the Aria-labelledby content

The above content is a small series to introduce the bootstrap Aria-label and Aria-labelledby application related content, hope this article to share can bring help to everybody, at the same time thanks everybody has been to cloud Habitat community website support.

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.