0

I am working on mobile site, and I wanted to do mouseover highlighting on my links which have class name "list_anchor" by using jQuery instead of using HTML's :hover pseudo selector. ('cause :hover is bit buggy in Android.)

So I followed this tutorial:
Stop the touchstart performing too quick when scrolling

and I successfully installed touchstart,touchmove function to my links. Happy for a while.

However, I have links which is lively loaded when users scroll(swipe) to the bottom of the page(like Twitter).
The Javascript does not seem to be applied for those links.

Here's what I got so far:

function touchEvent() {
    var self = $(this);
    self.addClass('hover');
    //behaviour for move
    self.on('touchmove', function(e){
        self.removeClass('hover');
    });     
}
$('a,section').filter('.list_anchor').on('touchstart', this, touchEvent);

Any help, suggestion appreciated.

Community
  • 1
  • 1
norixxx
  • 2,549
  • 2
  • 19
  • 26

1 Answers1

2

For on to work like the old live you need to attach it to something high up the DOM, and put the selector in the parameters, e.g.:

$(document).on('touchstart', '.list_anchor', touchEvent);
Owlvark
  • 1,763
  • 17
  • 28