React框架DIV文本内容全选并复制例子

        case "onDoubleClickCapture":
            if(a.elementType=='div'){
                    if(a.memoizedProps.className=="text_container"){
                    var div=a.return.child.return.stateNode;
                    //console.log(div.innerText);
                    var selection = window.getSelection();
                    var range = document.createRange();
                    range.selectNodeContents(div);
                    selection.removeAllRanges();
                    selection.addRange(range);
                    document.execCommand("Copy");
            }              
            }

原创文章,作者:何故,如若转载,请注明出处:https://www.htm5.cn/1463.html

(0)
何故何故
上一篇 2022年11月2日
下一篇 2022年11月4日

相关推荐

冀公网安备13098302131197号