I can't seem to get this click/touch event to work on iOS devices, but Android, Desktop, etc, everything is fine. The only time I can't get the alerts to work is when I'm testing on an iPhone or iPad. Other posts have suggested using...
bind.('click touchend'...
bind.('click tap'...
on.('touchstart touchend'...
as well as adding onclick=""
to the element or including cursor:pointer
in the CSS. I've tried all of these, but no luck.
Also, I'm using jQuery 1.11.1.
HTML
<div class="sort-selector">
Sort by:
<span class="active aButton" id="recent" onclick="">Most Recent</span>
|
<span class="aButton" id="alpha" onclick="">Alpha by City</span>
</div>
CSS
.sort-selector {
font-size: 17px;
display: table;
margin: 0 auto;
padding-top: 1em;
margin-bottom: 1em;
}
.sort-selector .aButton {
color: #a51722;
display: inline-block;
cursor: pointer;
}
.sort-selector .aButton.active {
color: #929191;
}
jQuery
$('.sort-selector .aButton').on('click', function(e) {
$('.sort-selector .aButton.active').removeClass('active');
$(this).addClass('active');
if ($(this).is('#alpha')) {
//a ton of stuff that isn't important
alert('alpha');
}
if ($(this).is('#recent')) {
//a ton of stuff that isn't important
alert('recent');
}
});
Aucun commentaire:
Enregistrer un commentaire