Skip to content

Instantly share code, notes, and snippets.

@asmt3
Created December 8, 2016 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asmt3/3acc55868a62eb0e8eecb2a636579013 to your computer and use it in GitHub Desktop.
Save asmt3/3acc55868a62eb0e8eecb2a636579013 to your computer and use it in GitHub Desktop.
Add classes to elements matching a certain CSS selector in jQuery
$(function(){
var selector = '.some-class';
$(selector).each(function(){
var $element = $(this);
$element.addClass('some-other-class')
$element.addClass('and-another-class')
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment