- ruby 2.0.0p247
- Rails 4.0.0
How to alternate the html content of my loop?
- @recipes.each do |recipe|
= image_tag "path.png", :height => "?", :width => "?"
Fox example:
The output expected is like:
image_tag "medium-01.png", :height => "200", :width => "350"
image_tag "small-02.png", :height => "183", :width => "285"
image_tag "small03.png", :height => "183", :width => "285"
image_tag "small-04.png", :height => "183", :width => "285"
image_tag "small-05.png", :height => "183", :width => "285"
image_tag "medium-06.png", :height => "200", :width => "350"
image_tag "medium-07.png", :height => "200", :width => "350"
image_tag "small-08.png", :height => "183", :width => "285"
image_tag "small-09.png", :height => "183", :width => "285"
Result desired bellow:
In jquery I did this. Maybe helps:
$("div").each(function(i, element) {
if (i % 5 == 0 || i % 6 == 0) {
$(this).css({"background":"dark_gray_color"});
}
else {
$(this).css({"background":"magenta_color"});
}
});
Am I clear?