JS按钮,已经有点击复制功能,现在需要实现复制+跳转链接功能,请问一下如何修改代码呢?
代码如下:
```javascript
$("#query-pane").on("click",".view_kami",function(event){
event.preventDefault();
var orderid = $(this).attr("data-orderid");
//$(this).attr({"disabled":"disabled"});
$.ajax({
type: "POST",
dataType: "json",
url: "/product/query/kami",
data: { "csrf_token": TOKEN,'orderid':orderid},
beforeSend: function () {
lodding = layer.load();
},
complete: function () {
layer.close(lodding);
},
error: function (data) {
ayer.close(lodding);
},
success: function(res) {
if (res.code == 1) {
var html = "";
var list = res.data;
for (var i = 0, j = list.length; i < j; i++) {
html += '<p id="km">'+list[i]+'</p>';
}
layer.open({
type: 1
,title: '快递单号'
,offset: 'auto'
,id: 'layerDemoauto' //防止重复弹出
,content: '<div style="text-align: center;padding: 20px 100px;">'+html+'</div>'
,btn: ['物流查询','关闭']
,btnAlign: 'c' //按钮居中
,shade: 0 //不显示遮罩
,yes: function(){
var clipboard = new ClipboardJS('.layui-layer-btn0', {
target: function() {
return document.querySelector("#km");
}
});
clipboard.on('success', function(e) {
//console.log(e);
layer.msg("复制成功");
});
clipboard.on('error', function(e) {
//console.log(e);
layer.msg("复制失败");
});
}
,no: function(){
layer.closeAll();
}
});
} else {
layer.msg(res.msg,{icon:2,time:5000});
}
return;
}
});
});
```