Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery toggle background?
    text
    copied! week <p>DKK</p> " id="radio2" value="75" /> <p>I have bunch of these div entry generated by while loop so I want to achieve this : WHEN input inside entry is clicked I want background image of entry div to change, but if I choose another radio in another entry div .. I'd like all previous changes( such as previous change of background) to go away and to change background of current div .. here is what I tried to do maybe you can help .. here is jquery below</p> <pre><code>$("input").click(function() { $(this).parent("div").toggle(function() { $(this).parent("div").css("background", "url(images/div_bg_hover.png)"); }, function() { $(this).parent("div").css("background", "url(images/div_bg.png)"); }); </code></pre> <p>Something is malfunctioning .. I mean code inst' working at all .. can anyone help me ? thank you</p> <hr> <p>I've tried both this :</p> <pre><code>$("input").click(function() { $("input").each(function() { if (this.checked) { $(this).parent("div").addClass("highlight"); } else { $(this).parent("div").removeClass("highlight"); } }); }); </code></pre> <p>AND </p> <pre><code>$("input").click(function() { $("input").each(function() { if (this.checked) { $(this).parent("div").css("background", "url(images/div_bg_hover.png)"); } else { $(this).parent("div").css("background", "url(images/div_bg.png)"); } }); }); </code></pre> <p>for some reason its not working at all not changing the background , maybe it has to do something with the code above here is the complete script :</p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function() { $(".left_navigation a:last").toggleClass('bolder'); $("input").each(function() { var element_value = $(this).val(); $(this).prev("p").append(" " + element_value + ",-"); }); $("input").click(function() { $("input").each(function() { if (this.checked) { $(this).parent("div").addClass("highlight"); } else { $(this).parent("div").removeClass("highlight"); } }); }); }); &lt;/script&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload