Created
December 8, 2016 09:42
-
-
Save asmt3/3acc55868a62eb0e8eecb2a636579013 to your computer and use it in GitHub Desktop.
Add classes to elements matching a certain CSS selector in jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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