js 将内容复制到剪切板

var addresss = $(this).prev('.con_li_address').text(); // 获取钱包地址信息
         $(this).next('input').val(addresss).select(); // 将地址信息加载到input中并设为选中状态
         document.execCommand('copy'); // 复制

将input设置为隐藏 设置display:none 和visiblity:hidden 状态都不可以复制成功

 input{
        background: rgba(0,0,0,0);
        border: none;
        height: 10px;
        outline: none;
        display: block;
        color: rgb(0,0,0,0);
    }
   input::selection{
        background: rgba(0,0,0,0);
    }

猜你喜欢

转载自blog.csdn.net/a1044187112/article/details/87861406