Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery copy table to clipboard

function selectElementContents(el) {
	var body = document.body, range, sel;
	if (document.createRange && window.getSelection) {
		range = document.createRange();
		sel = window.getSelection();
		sel.removeAllRanges();
		try {
			range.selectNodeContents(el);
			sel.addRange(range);
		} catch (e) {
			range.selectNode(el);
			sel.addRange(range);
		}
	} else if (body.createTextRange) {
		range = body.createTextRange();
		range.moveToElementText(el);
		range.select();
	}
}
Comment

jquery copy to clipboard

document.execCommand("copy");
Comment

copy to clipboard jquery

function copy(elem, type = 'input') {

  let text = '';
  
  //define the target text;
  if (type === 'input')
    text = $(elem).val();
  else 
    text = $(elem).text();

  //append input element to body to store target text
  var temp = $("<input>");
  $("body").append(temp);

  temp.val(text).select();   //select text to make it able executable
  document.execCommand("copy"); //run the copy command.

  temp.remove(); // remove input element from DOM after Execute copy command.

  // add effect to element to user notice copy execution.
  let notify =  $('<i class="fas fa-keyboard fa-2x text-info bg-light">Copied!!</i>');
  $(elem).closest('div').find('.fas').prepend(notify); 
  notify.css('display', 'block')
  notify.fadeOut(2000); 

}
Comment

PREVIOUS NEXT
Code Example
Javascript :: enable button 
Javascript :: npm run build serve 
Javascript :: strpos in javascript 
Javascript :: multithreading in javascript 
Javascript :: js if else 
Javascript :: discord.js lockdown command 
Javascript :: create directory when writing to file in nodejs 
Javascript :: using / for division is deprecated and will be removed in dart sass 2.0.0 
Javascript :: materialize open modal on load 
Javascript :: a.reduce 
Javascript :: jquery countdown timer 
Javascript :: js if string not empty 
Javascript :: render css express js 
Javascript :: open in a new tab react 
Javascript :: sequelize operators 
Javascript :: remove table line button html using javascript 
Javascript :: change href javascript 
Javascript :: material app routes 
Javascript :: javascript delay action 
Javascript :: moment is date equals 
Javascript :: js jquery include external script 
Javascript :: track scroll javascript 
Javascript :: npm config proxy 
Javascript :: js caps first letter 
Javascript :: how to use put to request in nodejs 
Javascript :: javascript size array 
Javascript :: js object contains key 
Javascript :: how to flat an array in javascript recursively 
Javascript :: js array.prototype.join 
Javascript :: change text in javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =