Skip to content

Instantly share code, notes, and snippets.

@leepettijohn
Created December 1, 2016 19:05
Show Gist options
  • Save leepettijohn/dad36c30c23be05abfed17dee37ab723 to your computer and use it in GitHub Desktop.
Save leepettijohn/dad36c30c23be05abfed17dee37ab723 to your computer and use it in GitHub Desktop.
Find class that starts with string and return the rest
$("div[class*='fa-']").each(function(){
var check = "fa-";
// Get array of class names
var cls = $(this).attr('class').split(' ');
for (var i = 0; i < cls.length; i++) {
// Iterate over the class and log it if it matches
if (cls[i].indexOf(check) > -1) {
console.log(cls[i].slice(check.length, cls[i].length));
return cls[i].slice(check.length, cls[i].length);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment