Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <input id="text" type="text">
<button id="btn">复制</button>
              
            
!

CSS

              
                
              
            
!

JS

              
                function handleCopyDDL(record){
    // 获取需要复制的文字
    const copyStr = record
    // 创建input标签存放需要复制的文字
    const oInput = document.createElement('input')
    // 把文字放进input中,供复制
    oInput.value = copyStr
    document.body.appendChild(oInput)
    // 选中创建的input
    oInput.select()
    // 执行复制方法, 该方法返回bool类型的结果,告诉我们是否复制成功
    const copyResult = document.execCommand('copy')
    // 操作中完成后 从Dom中删除创建的input
    document.body.removeChild(oInput)
    // 根据返回的复制结果 给用户不同的提示
    if (copyResult) {
      console.log('复制成功')
    } else {
      console.log('复制失败')
    }
  }

  document.getElementById('btn').onclick = function () {
    const text = document.getElementById('text').value;
    handleCopyDDL(text)
  }
              
            
!
999px

Console