You can simply leave the work to the browser through a CSS Media Query:
@media only screen and (max-width: 760px) {
/* esconde o elemento de controlo caso em Mobile */
#el-controlo { display: none; }
}
On your page, you add an empty element that will be hidden when on mobile:
<span id="el-controlo"></span>
Finally, with jQuery you add the CSS class you want if your control element is hidden:
$( document ).ready(function() {
// se elemento controlo escondido
if ( $('#el-controlo').css('display')=='none' ) {
// adiciona classe "dropup"
$('#meu-elemento').addClass('dropup');
}
});
The example above can be drastically reduced to a JavaScript condition using Window.matchMedia()
:
if (!window.matchMedia("(min-width: 760px)").matches) {
$('#meu-elemento').addClass('dropup');
}