Mobile-side CSS implements active Pseudo-class

Source: Internet
Author: User

Today encountered mobile phone side of the CSS in a tag active does not work, originally wanted to loop a tag, to the current a tag to add class to solve, can feel a little trouble, after checking the information to understand to solve this problem, only need to add a touchstart empty event can be.

Examples are as follows:

<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<style>
*{margin:0; padding:0;}
. domain a{Display:inline-block; border:1px solid #ccc; padding:5px 10px; margin:10px;}
. Domain a:active{background-color: #c00; color: #fff;}
</style>
<body>
<div class= "domain" id= "js-domain" >
<a href= "#" > Click 1</a>
<a href= "#" > Click 2</a>
</div>

<script>
Window.onload = function () {
var Doma=document.getelementbyid ("Js-domain"). getElementsByTagName (' a ');
for (Var i=0;i<doma.length;i++) {
Doma[i].addeventlistener (' Touchstart ', function () {},false);
};
}
</script>

</body>

Mobile-side CSS implements active Pseudo-class

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.