views:

718

answers:

3
A: 

This line: $("input").parent("div").css("background", "url(images/div_bg.png)" is causing all of the other items to reset to normal, allowing you to only have 1 active state at a time. You could scope it to the row so that each row may have one item selected.

Mark Hurd
"You could scope it to the row so that each row may have one item selected." - How do I do that ? tnx
c0mrade
A: 

You're only assigning behavior to the item clicked, rather than all selected input boxes. You might want to make a function as such:

function foo()
{
   $('input :selected').css(bar);
}

Now whenever you get a click event on an input event, call bar. You may need to modify foo to meet your specifications.

Stefan Kendall
This seems to partially work, thank you , I guess I forgot to mention that only 1 radio can be selected per row therefore also one div in a row can change background I modified code slightly as you suggested $("input").click(function() { $('input :selected').parent("div").css("background", "url(images/div_bg.png)"); $(this).parent("div").css("background", "url(images/div_bg_hover.png)");anything else you recommend ?
c0mrade
+3  A: 

What is the purpose of your second line of jquery?

$("input").parent("div").css("background", "url(images/div_bg.png)");

This is going to reset the background of all the "entry" divs. If I understand your objective correctly I think you want:

$(this).parent("div").siblings("div.entry").css("background", "url(images/div_bg.png)");

That way only the siblings of the entry you are changing will get their backgrounds reset.

On a side note, you have multiple divs with the same id, which is not a good idea.

Joel Potter
I changed id entry to class entry, mistake yes , but when I delete second row $(this).parent("div").css("background", "url(images/div_bg.png)"); //THIS Then when I click all my divs become green
c0mrade
thank you that was the solution
c0mrade