Created
March 21, 2012 15:07
-
-
Save jameswbutts/2148108 to your computer and use it in GitHub Desktop.
JQuery to apply classes to floated wysiwyg images
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
/** | |
* Applies .left or .right to images with inline floats. | |
* Useful for wysiwyg editors that use inline styles for alignment. | |
* Wrap wysiwyg output in a class to target (.wysiwyg) | |
*/ | |
$(document).ready(function(){ | |
$(".wysiwyg img").each(function(index, value) { | |
if( $(this).css('float')=='left' ){ | |
$(this).addClass("left"); | |
}else if( $(this).css('float')=='right' ){ | |
$(this).addClass("right"); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment