Q:

Copying text to clipboard isn't working for multiple records

  In the image above is what i'm trying to do....i need the ip copied to clipboard when the user clicks the button  but everytime i click any of the buttons assosciated with each ip, only the 1st IP gets copied whereas i want to copy the ip that is next to the button..... 
Here's my code: 
    @foreach ($name as $card)
    <li class="list-group-item"><span id="copy2">{{ $card->vhackIP }}</span> | {{ $card->name }} | {{ $card->description }}
        <button class="btn btn-success btn-xs" data-clipboard-target="#copy2">Copy IP</button>
    </li>
@endforeach

Everytime only the first ip gets copied....If someone can help me or tell me another way of making it happen ,i'll appreciate it....Thanks. 

A:

The problem seems the <span id="copy2"> and the data-clipboard-target attribute of the <button> because they are hard coded and not dynamic for each $card.  The values of the id and data-clipboard-target are the same on the whole list.  Try something like this:
@foreach ($name as $card)
    <li class="list-group-item"><span id="copy{{ $card->id }}">{{ $card->vhackIP }}</span> | {{ $card->name }} | {{ $card->description }}
         <button class="btn btn-success btn-xs" data-clipboard-target="#copy{{ $card->id }}">Copy IP</button>
    </li>
@endforeach

