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
use touchstart
:
$('ul.selectdropdown >li a').on('click touchstart',function(){
if ($(this).attr('target')==='_blank'){
window.open(this.href);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.