我正在使用 window.getSelection()。addRange(range)选择要复制的文本:
var targetelement = document.getElementById("someid"),
range = document.createRange();
range.selectNode(targetelement);
window.getSelection().addRange(range);
document.execCommand('copy')
它可以工作,但是浏览器(firefox)在代码完成后选择标签内的文本。我该如何选择呢? window.getSelection 函数或方法是否与之相反?
答案 0 :(得分:1)
<div id="someid">
This is a test man
</div>
<div id="empty">
</div>
<script>
var targetelement = document.getElementById("someid");
var range = document.createRange();
range.selectNode(targetelement);
window.getSelection().addRange(range);
document.execCommand('copy');
window.getSelection().removeAllRanges();
</script>
答案 1 :(得分:1)
答案 2 :(得分:1)
此旧代码可在所有浏览器中使用:
with a (status, date, amount, next_status) as (
select status, date, amount,
lead(status) over(order by date) as next_status
from my_table
)
select * from a
where status = 'c' and next_status <> 'n'