JavaScript - Copy text with clipboard.js based on class name -


i'm trying copy-to-clipboard function work below html-code using clipboard.js library:

<table id="test"> <tr><td class="c2c"><a id="1" class="btn fa fa-clipboard fa-2x" data-clipboard-action="copy" data-clipboard-target="1" data-value="http://some/link/1"></a></td></tr>   <tr><td class="c2c"><a id="2" class="btn fa fa-clipboard fa-2x" data-clipboard-action="copy" data-clipboard-target="2" data-value="http://some/link/2"></a></td></tr>   <tr><td class="c2c"><a id="3" class="btn fa fa-clipboard fa-2x" data-clipboard-action="copy" data-clipboard-target="3" data-value="http://some/link/3"></a></td></tr>   </table> 

as can see value/id changes each td or a-element.

instead of id can use class element work clipboard.js?

with code correct values cannot work clipboard.js:

    $("#test").on('click', '.btn', function (e) {         e.preventdefault();         var id = $(this).data('value');         console.log(id)     }); 

how can value of data-value attribute each td , have copied clipboard.js?

thank you.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -