Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2008
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    select div in a row

    Hiya all, I'm really stuck .. here is my html :
    Code:
    <!-- Beginning of ROW !-->
    <div id="row1">
    <div class="entry">
    free
    <span>some text</span>
    <p>DKK</p>
    <input type="radio" name="row<?php echo $counter?>" id="radio" value="0" />
    
    </div>
    
    <div class="entry">
    week
    <span></span>
    <p>DKK</p>
    <input type="radio" name="row<?php echo $counter?>" id="radio2" value="75" />
    </div>
    </div>
    <!-- End of ROW !-->
    <!-- Beginning of ROW !-->
    <div id="row2">
    .... same as in row 1
    </div>
    <!-- End of ROW !-->
    nth row ..
    here is Jquery

    Code:
    $("input").click(function() {
                        $("input").parent("div").css("background", "url(images/div_bg.png)");
                        $(this).parent("div").css("background", "url(images/div_bg_hover.png)");
                                                });

    What I'm trying to do .. is when I select a radio input the div in which it is located should change background and it works perfectly if there is only one row, but for instance if I try to select the value in first row then I select value in second row.. the div in second row where radio input is located changes background as it should but the div in first row reverse itself to other background although input remained checked .. here is what I'm trying to achieve


    And here is what I achieve :


  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    This:

    Code:
    $("input").parent("div").css("background", "url(images/div_bg.png)");
    Is setting the background image of every div that contains an input tag. You call that function every time an input is clicked on.


  •  

    Posting Permissions

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