Skip to content

Instantly share code, notes, and snippets.

@angelo
Created April 2, 2014 23:03
This bit of coffee handles the card finder style changes on http://creditcardreviews.com/. I used data attributes to define the card type for each button. This code updates the button and illustration styles when a user chooses a type of card to search for. It also updates the hidden 'type' field to send this information when the form is submitted.
$('.find-cards form a.button').click ->
$this = $ this
$this.addClass('active').siblings().removeClass 'active'
$('.types').removeClass('personal business student').addClass($this.data('type'))
$('#type').val $this.data('slug')
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment