iOS automatic hover fix?

前端 未结 8 703
春和景丽
春和景丽 2020-12-04 17:01

Is there a jQuery plugin or JavaScript script that automagically loops through each CSS hover (found in an external stylesheet) and binds it with a double touchdown event?

8条回答
  •  情歌与酒
    2020-12-04 17:45

    There is no jQuery plugin that I know of to do such a thing.

    You cannot trigger a css psuedo class such as ":hover". You can however loop through the anchor elements and add a css class ".hover" on touchstart and touchend events as follows:

        var pageLinks = document.getElementsByTagName('a');
    for(var i = 0; i < pageLinks.length; i++){
        pageLinks[i].addEventListener('touchstart', function(){this.className = "hover";}, false);
        pageLinks[i].addEventListener('touchend', function(){this.className = "";}, false);
    }
    

    To add a double finger tap gesture recognizer, you can use a plugin such as: http://plugins.jquery.com/project/multiswipe

提交回复
热议问题