Mads
Mads

Reputation: 27

onClick event in jQuery mobile do not work

I am new to jQuery and have made a page with some buttons i want to do some actions when they are clicked.

I have made a jsFiddle with my code.

When I execute the code on my laptop with chrome, it works fine. But when I execute it from my mobile phone (also with chrome) it do not activate the function.

I have tried to google for hours to find a solution and have tried something like:

    $(document).on('pagebeforeshow', '#front', function(){ 
        $(document).on('click', '#ssStart', function(){ 
            alert('Alerted!');       
        });    
    });

but I cannot get it to work.

Can anyone please help me?

Upvotes: 0

Views: 528

Answers (2)

user2809321
user2809321

Reputation: 204

Through a mobile browser, a tap is registered differently than a click so for your buttons you have to change their pointers to cursors through CSS

    #start, #prev, #next{
    cursor: pointer;
}

Upvotes: 1

MrCrimsonKing
MrCrimsonKing

Reputation: 34

I have changed your code just a little bit in this:

https://jsfiddle.net/1uuduxtL/

$(function() {
    $("#start").click(function() {
       alert("start"); 
    });
    $("#prev").click(function() {
        alert("prev");
    });
    $("#next").click(function() {
        alert("next");
    });
})();

Upvotes: 0

Related Questions