Created
August 29, 2011 09:23
-
-
Save anonymous/1178074 to your computer and use it in GitHub Desktop.
Wrap box for my current project
This file contains 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
$('.borderedBox, #content').each(function(){ | |
var t = $(this), | |
mainClasses = this.className, | |
mainIds = this.id; | |
if (mainClasses.length > 0 && !mainIds.length) { //Wrap for elements which has only class | |
t.wrap('<div class="'+mainClasses+'" />'); | |
} | |
if (mainClasses.length > 0 && mainIds.length > 0) { //Wrap for elements which has both, class and id | |
t.wrap('<div class="'+mainClasses+'" id="'+mainIds+'" />'); | |
} | |
if (mainIds.length > 0 && !mainClasses.length) { //Wrap for elements which has only id | |
t.wrap('<div id="'+mainIds+'" />'); | |
} | |
t.removeAttr('class'); //Remove class attribute from original element | |
t.removeAttr('id'); //Remove id attribute from original element | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment