Eslam Saeed
Eslam Saeed

Reputation: 416

jQuery on click function not working in Android mobile browsers

This jQuery onclick function works perfectly in all computer browsers but when run on Android mobile devices' default browser it doesn't. It does work in Chrome mobile browser.

html

<input type="button" value="Add" id="submit" class="btn btn-primary"/>
<div class="table-responsive " style= "max-width:900px;">
  <table class="table table-bordered">
    <thead>
      <tr>
        <th style="width:20px">#</th>
        <th>code</th>
        <th>credit</th>
        <th>Grade</th>
      </tr>
    </thead>
    <tbody class="tableBody">
    </tbody>
  </table>
</div>

js

 $(document).ready(function() {
        var i=0;
        var code;
        var credit=0;
        var grade=0;


        $('#submit').click(function (){
            i=i+1;
            code=$('input[name=codeInput]').val();
            credit=$('select[name=quantity]').val();
            grade=$('select[name=gradetInput]').val();
            $('.tableBody').append( '<tr class="trow">'+'<td>' + i +'</td>'+'<td>' + code +'</td>'+'<td>' + credit +'</td>'+'<td>' + grade +'</td>'+'</tr>');
        });
    });

Upvotes: 2

Views: 1178

Answers (3)

Not sure why this is an issue, but try adding this rule:

.dropdown-backdrop {
 z-index: -1;
}

Upvotes: 0

Vasily  Vlasov
Vasily Vlasov

Reputation: 171

try use touchstart, like this:

$('#submit').bind('touchstart click', function(){
    i=i+1;
    code=$('input[name=codeInput]').val();
    credit=$('select[name=quantity]').val();
    grade=$('select[name=gradetInput]').val();
    $('.tableBody').append( '<tr class="tenter code hererow">'+'<td>' + i +'</td>'+'<td>' + code +'</td>'+'<td>' + credit +'</td>'+'<td>' + grade +'</td>'+'</tr>');
});

Upvotes: 1

user3339197
user3339197

Reputation:

https://github.com/ftlabs/fastclick

$(function() {
    FastClick.attach(document.body);
});

profit, but hey what is i in your code?

Upvotes: 0

Related Questions