jQuery Get data-attribute of all checkbox into a string
<p>I have a list of checkboxes that looks like this:</p>

<pre><code>&lt;input type="checkbox" class="pcb" value="1" data-id="99"&gt;
&lt;input type="checkbox" class="pcb" value="2" data-id="98"&gt;
&lt;input type="checkbox" class="pcb" value="3" data-id="97"&gt;
</code></pre>

<p>And originally I only needed the value inside the value attribute of the checked checkbox. I use this javascript/jquery code to do that:</p>

<pre><code>var receiptNos = $("#result input:checkbox:checked").map(function () {
   return $(this).val();
}).get();
</code></pre>

<p>Using this code gives me: <code>receiptNos = '1,2,3'</code>
Now I need to have another string variable that will hold the content of data-id of all checked checkboxes: <code>receiptNos2 = '99,98,97'</code></p>

<p>I tried using:</p>

<pre><code>var receiptNos2 = $("#result input:checkbox:checked").attr('data-id').map(function () {
   return $(this).val();
}).get();
</code></pre>

<p>but it doesn't work. Any ideas?</p>