Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When doing this -> <code>$('.item-name');</code></p> <p>You are just capturing the element as object but not the value.</p> <p>Now that you got your element as object, you need to extract the value and, in this case, your element object is a <code>div</code> so you can try <code>.text()</code> or <code>.html()</code> (to get the text or html inside the div).</p> <p><em>(For this situation I will use <code>text()</code> cause you are working just with values and there is nothing related to html)</em></p> <p><strong>Try this:</strong></p> <pre><code>var name = $('.item-name'); var price = $('.item-price'); var quantity = $('.item-quantity'); var data = name.text() + price.text() + quantity.text(); $('#items').html(data); </code></pre> <hr> <h2>Better solution:</h2> <p>This will make clickable the <code>div</code> in which you have the product and match the <strong>cartItem_SCI</strong> pattern.</p> <p>So, when user clicks any of the elements of your cart, you will get the <code>name</code>, <code>price</code> and <code>quantity</code> values that will be attached to the <code>$('#items')</code> div using <code>append()</code> method instead of <code>html()</code> <em>(because using this will replace the product information each time the user clicks a div)</em></p> <pre><code>$(document).ready(function() { $('div[id^="cartItem_SCI-"]').css({ cursor:'pointer' }); $('div[id^="cartItem_SCI-"]').click(function() { var name = $(this).find('.item-name'); var price = $(this).find('.item-price'); var quantity = $(this).find('.item-quantity'); var data = name.text() + ' - ' + price.text() + ' - ' + quantity.text(); $('#items').append(data + '&lt;br/&gt;'); }); });​ </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload