Skip to content

Instantly share code, notes, and snippets.

@overwine
Last active December 14, 2015 20:49
Show Gist options
  • Save overwine/5146709 to your computer and use it in GitHub Desktop.
Save overwine/5146709 to your computer and use it in GitHub Desktop.
DERP
<li>
<div class="category">
<div class="cat-text">TYPE</div>
<div class="rotate-arrow-down"></div>
</div>
<div class="subcategories"style="display:inherit;">
<div class="clearfix subcategory">
<input type="checkbox" name="selcategory[0]" value="1"><label>APPETIZERS</label>
</div>
<div class="clearfix subcategory">
<input type="checkbox" name="selcategory[1]" value="2"><label>SOUPS</label>
</div>
<div class="clearfix subcategory">
<input type="checkbox" name="selcategory[2]" value="3"><label>SALADS</label>
</div>
<div class="clearfix subcategory">
<input type="checkbox" name="selcategory[3]" value="4"><label>MAIN DISHES</label>
</div>
<div class="clearfix subcategory">
<input type="checkbox" name="selcategory[4]" value="5"><label>SIDE DISHES</label>
</div>
<div class="clearfix subcategory-hidden" style="display:none;">
<input type="checkbox" name="selcategory[5]" value="23"><label>SANDWICHES</label>
</div>
<div class="clearfix subcategory-hidden" style="display:none;">
<input type="checkbox" name="selcategory[6]" value="6"><label>DESSERTS</label>
</div>
<div class="clearfix subcategory-hidden" style="display:none;">
<input type="checkbox" name="selcategory[7]" value="22"><label>BREAKFAST</label>
</div>
<div class="view-all">VIEW ALL TYPE</div>
</div>
</li>
$('.view-all').click(function() {
$(this).prevAll(".subcategory-hidden").slideToggle();
var value = $(this).text();
if($(this).parent().children(".subcategory-hidden").is(':visible')) {
value = value.replace("ALL", "LESS");
$(this).text(value);
} else {
value = value.replace("LESS", "ALL");
$(this).text(value);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment