| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 85 人关注过本帖
标题:如何让3个button别作用?
只看楼主 加入收藏
Z89
Rank: 2
等 级:论坛游民
威 望:1
帖 子:91
专家分:32
注 册:2022-4-26
结帖率:66.67%
收藏
 问题点数:0 回复次数:0 
如何让3个button别作用?
                             <div class="pwd3"><button onClick="copyText()"><strong>製表單1</strong></button></div>                            <hr>                            <div id="myDiv" class="pwd2"><p>表單1內容:xxxxx<br /></div>                            <div class="pwd4"><button onClick="copyText()"><strong>製表單2</strong></button></div>                            <hr>                            <div id="myDiv1" class="pwd2"><p>表單2內容:xxxx<br /></div><script>        function copyText() {            // 選取<div>元素的內容            const divText = document.getElementById("myDiv").textContent;            // 建立一個臨時的文本區域元素            const tempTextarea = document.createElement("textarea");            tempTextarea.value = divText;            // 將文本區域元素加入到DOM中            document.body.appendChild(tempTextarea);            // 選取文本區域內的文字            tempTextarea.select();            // 複製選取的文字到剪貼板            document.execCommand("copy");            // 刪除臨時的文本區域元素            document.body.removeChild(tempTextarea);            // 顯示複製成功的提示            alert("表單已複製");        }    </script>   

搜索更多相关主题的帖子: div class document strong button 
2024-03-23 21:22
快速回复:如何让3个button别作用?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.010903 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved