pass value of cell from table row to variable

I am attempting to pass the value of the data-count cell to a variable using either jQuery or Javascript. How can I do it? Here is the HTML:

edit I should have stated that the value of id-offer=186000 is not constant and differs from page to page

<table class="vis" id="own_offers_table">
    <tbody>
        <tr class="offer_container " id="offer_186000" data-id="186000" data-count="30" data-village="" data-wanted_wood="900" data-wanted_stone="0" data-wanted_iron="0">

Thanks again for any help

Answers 1

  • var count = $('#offer_186000').data('count');
    

    Setting the value:

    $('#offer_186000').data('count', value);
    

    If you can't use it's id

    $('#own_offers_table').find('.offer_container').data('count');
    

    For Setting the value:

    $('#own_offers_table').find('.offer_container').data('count', value);
    

Related Articles