I've noticed that the bootstraps menu does not close after selecting an option when using a mobile phone, so I want to run only if it's on a mobile phone, I'm doing this, would it be the correct one? Thank you
<script>
jQuery(document).ready(function($){
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad|android)/);
if (agentID) {
alert('você está utilizando um celular');
$('.nav a').on('click', function(){
//$('.btn-navbar').click(); //bootstrap 2.x
$('.navbar-toggle').click() //bootstrap 3.x
});
} else {
alert('você está em um computador');
}
});
</script>