Skip to content

Instantly share code, notes, and snippets.

@dacur
Created October 7, 2014 13:45
Show Gist options
  • Select an option

  • Save dacur/7da1d3660b75f1072ab1 to your computer and use it in GitHub Desktop.

Select an option

Save dacur/7da1d3660b75f1072ab1 to your computer and use it in GitHub Desktop.
Iterating over child elements to determine if an element does NOT have a certain class. Child element icons have a default class of 'opacity50' that makes them grey instead of black. When clicked, that class is removed, making the selected icon black. Uses Font Awesome icons.
function JournalScale(){
$('#journalScale').children('i').each(function(){
if(!$(this).hasClass('opacity50')){
_smileySelected = (this).id;
}
});
}
.opacity50 { opacity: 0.5; }
#journalScale
i.fa.fa-smile-o.fa-3x.opacity50.journalFeeling#journalSmile
i.fa.fa-meh-o.fa-3x.opacity50.journalFeeling#journalMeh
i.fa.fa-frown-o.fa-3x.opacity50.journalFeeling#journalFrown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment