Copy text string on click

后端 未结 8 1993
我在风中等你
我在风中等你 2020-11-27 02:31

I spent a good 20 min searching online for this, but couldn\'t find it. What I want is to to be able to copy a text string on click without a button. The text strin

8条回答
  •  我在风中等你
    2020-11-27 03:16

    function copy(that){
    var inp =document.createElement('input');
    document.body.appendChild(inp)
    inp.value =that.textContent
    inp.select();
    document.execCommand('copy',false);
    inp.remove();
    }

    hello man

提交回复
热议问题