Hi,

I'm trying to write some jquery code so when i click on the relevent
item price, it alerts me with the quantity of that item and also
displays the content of the h2 header just before the relevant table,
is there a way somehow of finding out the index of the 'td' which is
clicked, and then extracting the quantity in the row above with the
same index. also be able to grab the text from the h2 header before
the table, so in effect, when i click on the '40p each' box within the
first item table, it alerts me with the quantity being 1000, and also
the h2 header of 'First Item Named here' Can someone please help!?

Example :

<h2 class="sublisting">First Item Named here</h2>
<p>information goes here</p>
<table class="price_table">
        <tr>
                <th> Quantity</th>
                <th> 1000 </th>
                <th> 5000 </th>
                <th> 10,000 </th>
                <th> 15,000 </th>
                <th> 20,000 </th>
        </tr>
        <tr>
                <td> Price </td>
                <td><strong>£400</strong><br />
                        <span class="each_item">40p each</span></td>
                <td><strong>£1650</strong><br />
                        <span class="each_item">33p each</span></td>
                <td><strong>£3200</strong><br />
                        <span class="each_item">32p each</span></td>
                <td><strong>£4800</strong><br />
                        <span class="each_item">32p each</span></td>
                <td><strong>£6200</strong><br />
                        <span class="each_item">31p each</span></td>
        </tr>
</table>

<h2 class="sublisting">second Item Named here</h2>
<p>information goes here</p>
<table class="price_table">
        <tr>
                <th> Quantity</th>
                <th> 1000 </th>
                <th> 5000 </th>
                <th> 10,000 </th>
                <th> 15,000 </th>
                <th> 20,000 </th>
        </tr>
        <tr>
                <td> Price </td>
                <td><strong>£400</strong><br />
                        <span class="each_item">40p each</span></td>
                <td><strong>£1650</strong><br />
                        <span class="each_item">33p each</span></td>
                <td><strong>£3200</strong><br />
                        <span class="each_item">32p each</span></td>
                <td><strong>£4800</strong><br />
                        <span class="each_item">32p each</span></td>
                <td><strong>£6200</strong><br />
                        <span class="each_item">31p each</span></td>
        </tr>
</table>

<script type="text/javascript">
//<![CDATA[
$('.each_item').parent().mouseover( function(){
        $(this).css('background-color','#F90');
        $(this).css('cursor','hand');
        $(this).css('cursor','pointer');
    }).mouseout(function() {
        $(this).css('background-color','#EFEFEF');
        $(this).css('cursor','default');
        }).click( function() {

         alert('display quantity based upon the pricebox and also
display the
previous h2 heading');
         } );

//]]>
</script>

Reply via email to