Skip to content

Instantly share code, notes, and snippets.

@jameswbutts
Created March 21, 2012 15:07
Show Gist options
  • Save jameswbutts/2148108 to your computer and use it in GitHub Desktop.
Save jameswbutts/2148108 to your computer and use it in GitHub Desktop.
JQuery to apply classes to floated wysiwyg images
/**
* 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