SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: using JQuery

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    302
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using JQuery

    I n have a <td> like below

    <td width="33" class=cellTextGreyLeft><input type="checkbox" class="selectColumn selectColumnAmericas column17 " name="strCustTerr1" value="" align="middle" /></td>

    I want to pick data

    Americas

    column17

    and 17

    when a user click on this td .

    what JQuery syntax I should be using here ?

  2. #2
    Learning...
    Join Date
    Jan 2003
    Posts
    781
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    html
    Code:
    <table border="1">
        <td width="33" class="cellTextGreyLeft">
            <input type="checkbox" 
                class="selectColumn selectColumnAmericas column17" 
                name="strCustTerr1" 
                value="" 
                align="middle" />
        </td>
    </table>
    2 clicks attached, to cell and to the check box. When you'll click the check box, both events for the check box and the td will fire as the check box is inside the td. Once you have the class value, split it, this will give you an array which in turn you can utilize.
    Code:
    <script type="text/javascript">
        $(document).ready(function(){
            //table cell click
            $('.cellTextGreyLeft').click(function(){
                //can use children and find both
                var myclassValues = $(this).children('input[name="strCustTerr1"]').attr('class');
                alert('td clicked = '+myclassValues);
                
    
            });
            //checkbox click
            $('input[name="strCustTerr1"]').click(function(){
                var myclassValues = $(this).attr('class');
                alert(myclassValues);
            });
    
        });
    
    </script>
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •