I have a list of checkboxes with associated images and titles in as labels. I run an each loop to pull the data for the checkboxes. I simply want the images to be highlighted when onclick. For some reason, the jQuery toggle script I'm using doesn't work inside the loop.
js:
<script>
$("img.choice").click(function() {
$(this).toggleClass("new").toggleClass("new1");
});
</script>
css:
.new {
padding-top: 0px;
padding-bottom: 0px;
margin-top: 0px;
margin-bottom: 0px;
box-shadow: 2px 2px 4px #888888;
}
.new:hover {
box-shadow: 2px 2px 2px #001f36;
border-color: #FF804D;
}
.new:active {
box-shadow: 2px 2px 2px #001f36;
border-color: #FF804D;
}
.new1 {
border: outset;
border-color: #FF804D;
}
html:
<div class="row" align='center'>
<% Category.select { |category| category.gender == 'girl' }.each do |category| %>
<div class="span4" align="center" style="padding-top:15px">
<label>
<div style="padding-bottom:5px">
<h13><%= category.name.capitalize %></h13>
</div>
<img id="choice-<%= category.id -%>" src= <%= category.image %> class="choice new" />
<div>
<%= check_box_tag 'category_ids[]', category.id %>
</div>
</label>
</div>
<% end %>
</div>
<% Category.where('gender == "girl"').each do |category| %>might be a better optiongem 'jquery-rails', '2.0.2'- sorry, the element with choice isn't there now, but I tried it on all thedivs,imgs, etc.idto that erb code?