我正在尝试通过使用下面的代码来复制到剪贴板操作,并且代码在桌面浏览器中运行良好,但是当涉及到 IOS safari/chrome 等移动浏览器时,页面会向下滚动$temp.val(copydatacode).select();
$('#myelementcopy').click(function(event){
var copydatacode= $('.addelement').html();
var $temp = $("<input>");
$("body").append($temp);
$temp.val(copydatacode).select(); // when the code execute at this line the mobile browser jumps to the page bottom
document.execCommand("copy");
$temp.remove();
return false;
event.preventDefault();
});