Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ZeroClipboard and Bootstrap
<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href=""/>
<script src=""></script>
<script src=""></script>
<script src="ZeroClipboard.js"></script>
.btn-clipboard {
position: relative;
right: 51px;
border-radius: 0 4px 0 4px;
.zeroclipboard-is-hover {
color: #fff;
border-color: #563d7c;
background-color: #563d7c;
<div class="container">
<h5>your code</h5>
<div class="row-fluid">
<div class="code-box">
<span class="btn btn-default btn-sm btn-clipboard pull-right" data-clipboard-target="code">
<pre id="code">
var odds = => v + 1);
var nums =, i) => v + i);
var pairs = => ({even: v, odd: v + 1}));
$(function () {
// zeroclipboard object
var clip = new ZeroClipboard($('.btn-clipboard'));
var clipElems = $(clip.elements());
// tooltip logic
var tooltipOptions = {title: 'Copy to clipboard', placement: 'top'};
clipElems.tooltip(tooltipOptions); {'bs.tooltip').options.title = 'Copied!';
clipElems.mouseleave(function () {'bs.tooltip').options.title = tooltipOptions.title;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment