T
T
tiger2015-11-02 00:30:19
JavaScript
tiger, 2015-11-02 00:30:19

Why doesn't JS work on mobile devices?

$(document).on('click', '.disabled-chat', function () {
        $(this).removeClass('disabled-chat');
        $(this).addClass('active-chat');
        $(".chat-right").css({"width":"327px","padding":"0 7px 0 7px"});
        return false;
    });

Let's say here's a normal trigger. On the computer everything is fine, on the tablet the click does not work. What is the problem?
Any click on some object with a class does not accept

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Serdji, 2015-11-02
@tigroid3

Try to do without delegation and return nothing from the function.

$( '.disabled-chat' ).on( 'click', function () {
        $( this )
            .removeClass( 'disabled-chat' )
            .addClass ( 'active-chat' );
        $( '.chat-right' ).css({
                 "width"   : "327px",
                 "padding" : "0 7px 0 7px"
         });
    });

Y
Yaroslav Lyzlov, 2015-11-02
@dixoNich

And one more thing: for mobile devices, it is better to use tap, not click. Click has a 300ms delay before firing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question