// Utilisation
$('#monBouton').copy("IdleBlog is op!!");
// Fonction
$.fn.extend({
copy : function (text) {
return $(this).click(function () {
var container = $('<span style="position:absolute;top:-1000px;">' + text + '</span>');
$('body').append(container);
var range = document.createRange();
var selection = window.getSelection();
selection.removeAllRanges();
range.selectNodeContents(container.get(0));
selection.addRange(range);
document.execCommand('copy');
selection.removeAllRanges();
container.remove();
});
}
});
Javascript
http://blog.idleman.fr/snippet-27-javascript-copier-dans-le-presse-papier-sans-flash-et-fonctionne-sur-ie/
<iframe width="100%" height="542" src="http://snip.yosko.net/index.php?embed=5807358eab602" type="text/html"></iframe>
Text only - Permalink - Snippet public post date 19/10/2016
//delay function
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
//usage (vanilla JavaScript)
var inputs = document.querySelectorAll('input');
for (var i = 0; i < inputs.length; i++) {
var input = inputs[i];
input.addEventListener('keyup', function(e) {
delay(function(){
console.log('Time elapsed!');
}, 1000 );
});
}
//usage (jQuery)
$('input').keyup(function() {
delay(function(){
console.log('Time elapsed!');
}, 1000 );
});
Javascript
http://stackoverflow.com/questions/1909441/jquery-keyup-delay
<iframe width="100%" height="668" src="http://snip.yosko.net/index.php?embed=5551b404949f0" type="text/html"></iframe>
Text only - Permalink - Snippet public post date 12/05/2015