Reputation: 551
I have a drop down list of links that I am converting into select box upon page load . This is working properly on desktop/laptops however it is not working on iphone/ipad.
I am totally new to this so I don't know what may be causing the issue because code seems to work fine and triggers page load on click event. Here is the code.
jQuery(document).ready(function ($)
{
$('ul.selectdropdown').each(function(){
var select=$(document.createElement('select')).insertBefore($(this).hide());
$('>li a', this).each(function(){
var a=$(this).click(function(){
if ($(this).attr('target')==='_blank'){
window.open(this.href);
}
else{
window.location.href=this.href;
}
}),
option=$(document.createElement('option')).appendTo(select).val(this.href).html($(this).html()).click(function(){
a.click();
});
});
});
});
Isn't click function suppose to work on all devices?
Ahmar
Upvotes: 1
Views: 2400
Reputation: 82241
use touchstart
:
$('ul.selectdropdown >li a').on('click touchstart',function(){
if ($(this).attr('target')==='_blank'){
window.open(this.href);
}
});
Upvotes: 2