1、剪贴板复制粘贴-JavaScript
<textarea id="sqlshow" style="resize:none"></textarea>
<input type="button" class="btn ..." onClick="copyUrl()" value="点击复制SQL" />
function copyUrl(){
var url=document.getElementById("sqlshow");
url.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
alert("已复制好,可贴粘。");
}
剪贴板复制粘贴
2、ajax翻页后的this失效问题
利用<a data-xx=""></a>
传值
<a href="#sqlshow" id="show-sql" data-sqlcontent="${sqls.info}">
${sqls.info}
</a>
翻页过后以下代码this会失效
$("a[id=show-sql]").on("click", function () {
document.getElementById("sqlshow").value = $(this).attr("data-sqlcontent");
});
改进代码后可以正常使用了!
$(document).on('click', "#show-sql", function () {
document.getElementById("sqlshow").value = $(this).attr("data-sqlcontent");
});
网友评论