Javascript jquery单击不在ipad/iphone上工作
我有一个链接的下拉列表,我在页面加载时将其转换为选择框。这在台式机/笔记本电脑上正常工作,但在iphone/ipad上不起作用 我对这个完全陌生,所以我不知道是什么导致了这个问题,因为代码似乎工作得很好,并触发了点击页面加载事件。这是代码Javascript jquery单击不在ipad/iphone上工作,javascript,jquery,iphone,ipad,Javascript,Jquery,Iphone,Ipad,我有一个链接的下拉列表,我在页面加载时将其转换为选择框。这在台式机/笔记本电脑上正常工作,但在iphone/ipad上不起作用 我对这个完全陌生,所以我不知道是什么导致了这个问题,因为代码似乎工作得很好,并触发了点击页面加载事件。这是代码 jQuery(document).ready(function ($) { $('ul.selectdropdown').each(function(){ var select=$(document.createElement('select')).
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();
});
});
});
});
点击功能不应该在所有设备上都起作用吗
Ahmar使用
touchstart
:
$('ul.selectdropdown >li a').on('click touchstart',function(){
if ($(this).attr('target')==='_blank'){
window.open(this.href);
}
});
这部分不起作用的问题是,这是单击实际需要激发选项=$(document.createElement('option')).appendTo(select).val(this.href).html($(this.html())。单击(function(){a.click();有错误吗?我看你的程序不工作了。它在iphone/ipad上不工作,上面的线程中提供的代码也不工作。请自己检查。对我也不工作,所有功能都与标准浏览器中的“单击事件”完美配合