Skip to content

Instantly share code, notes, and snippets.

@hsleonis
Created April 2, 2016 10:13
Show Gist options
  • Select an option

  • Save hsleonis/067041c484cfc41f161d026e73b97a5b to your computer and use it in GitHub Desktop.

Select an option

Save hsleonis/067041c484cfc41f161d026e73b97a5b to your computer and use it in GitHub Desktop.
Toogle css class without conditions
/**
* Toggle two classes
*/
$("#toggler").toggleClass("lightOn lightOff");
/**
* Wrap an HTML structure around each element in the set of matched elements
* Reference: http://api.jquery.com/wrap
*/
$( ".inner" ).wrap( "<div class='new'></div>" );
// or
$( ".inner" ).wrap(function() {
return "<div class='" + $( this ).text() + "'></div>";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment