JavaScript Individual tooltip when using multiple buttons with clipboard.js

I have a page with two textareas and two buttons that copy the content of each textarea respectively to the user's clipboard when pressed. When the button is pressed and the copying is successful, a tooltip shows saying Copied!. With how I had it set up before, when 1 button was pressed, then a tooltip was shown for both buttons instead of just the one pressed (see here).

$('button').tooltip({
  trigger: 'click',
  placement: 'bottom'
});

function setTooltip(message) {
  $('button').tooltip('hide')
    .attr('data-original-title', message)
    .tooltip('show');
}

function hideTooltip() {
  setTimeout(function() {
    $('button').tooltip('hide');
  }, 1000);
}

var clipboard = new Clipboard('button');

clipboard.on('success', function(e) {
  e.clearSelection();
  setTooltip('Copied!');
  hideTooltip();
});

clipboard.on('error', function(e) {
  e.clearSelection();
  setTooltip('Failed!');
  hideTooltip();
});

After basically duplicating the code above I managed to make it so that a tooltip is only shown for the button that is clicked (see here), but this seems like a very beginner-ish way to do it (which I am).

Answer:1

I am having trouble with noUislider, in that I need to be able to differentiate between different sliders when slide events are triggered. I thought (and from reading the noUiSlider GitHub) that I'd ...

I am having trouble with noUislider, in that I need to be able to differentiate between different sliders when slide events are triggered. I thought (and from reading the noUiSlider GitHub) that I'd ...

  1. nouislider slide event

I have this array and I want to count total numbers into this, can anyone please let me know how can i achieve this using pure javascript var total = { "numbers":{ "1":"9897877884", ...

I have this array and I want to count total numbers into this, can anyone please let me know how can i achieve this using pure javascript var total = { "numbers":{ "1":"9897877884", ...

  1. count length array php
  2. count length array javascript
  3. count length array python
  4. count length array jquery
  5. count length array
  6. count length array java
  7. count length array vba
  8. count length array angularjs
  9. count array length in c#
  10. count array length js
  11. count array length mongodb
  12. count array length online
  13. count array length in angular 4
  14. count array length in typescript
  15. count array length bash
  16. count array length powershell
  17. count array length in twig
  18. count array length in angular 6
  19. count length of array in react
  20. laravel count array length

I have successfully uploaded files to Firebase's storage via Google Cloud Storage through JS! What I noticed is that unlike files uploaded directly, the files uploaded through Google Cloud only have a ...

I have successfully uploaded files to Firebase's storage via Google Cloud Storage through JS! What I noticed is that unlike files uploaded directly, the files uploaded through Google Cloud only have a ...

I have just started a school assignment where they want me to detect and recognize objects in a webcam stream, in an webgl application. It will be added to an already existing javascript plugin. It is ...

I have just started a school assignment where they want me to detect and recognize objects in a webcam stream, in an webgl application. It will be added to an already existing javascript plugin. It is ...

  1. real time motion capture
  2. real time motion tracking
  3. real time motion planning
  4. real time motion capture blender
  5. real time motion capture unity
  6. real time motion capture animation
  7. real time motion detection
  8. real time motion graphics
  9. real time motion capture software
  10. real time motion detection matlab code
  11. real time motion detection opencv
  12. real-time motion planning for agile autonomous vehicles
  13. real time motion blur
  14. real time motion studios
  15. real time motion control
  16. real time motion graphics software
  17. real-time motion planning with dynamic obstacles
  18. real time motion interpolation
  19. real time motion
  20. real-time motion tracking from a mobile robot