<script type="text/javascript">
var cutTextareaBtn = document.querySelector('.js-textareacutbtn');
cutTextareaBtn.addEventListener('click', function(event) {
var cutTextarea = document.querySelector('.js-cuttextarea');
cutTextarea.select();
try {
var successful = document.execCommand('cut');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Cutting text command was ' + msg);
} catch(err) {
console.log('Oops, unable to cut');
}
});
</script>
所以,这适用于IE和Chrome,但我怎么能让它在Firefox中运行?我需要认真的帮助,我不知道如何将js转换为jQuery ..或者如果您对我的代码有解决方案,请随时发布。任何帮助将不胜感激。