I want to add img-responsive to all img in some HTML that I get from summernote text. I thought this would work, but it does not. Perhaps because the img tag does not have a class attribute?
Example of the html
<p><img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABI...."></p>
Here is my code:
var rawHtml = $("#summernote").summernote('code');
$(rawHtml).find('img').each(function () {
$('img').addClass('img-responsive');
});
UPDATED: Error fixed. It should work now
You need to get code
back to #summernote
.
Try this one:
var rawHtml = $($('#summernote').summernote('code'));
rawHtml.find('img').each(function () {
$('img').addClass('img-responsive');
});
$('#summernote').summernote('code',
rawHtml.html();
);