admin管理员组文章数量:1401149
I upload an image with the ck editor. When i select and upload the file, the editor automatic write the image width and height.
If i dont write in to this two field manualy 100% and 100%, how can i edit this with jquery? With this code, it writes the width and height to 100%, but the ck editor add these features into style attr.
$('div.content img').attr('width', '100%');
$('div.content img').attr('height', '100%');
How can i modify the img-s style attr with jquery, and set width and height to 100%?
Thank you!
I upload an image with the ck editor. When i select and upload the file, the editor automatic write the image width and height.
If i dont write in to this two field manualy 100% and 100%, how can i edit this with jquery? With this code, it writes the width and height to 100%, but the ck editor add these features into style attr.
$('div.content img').attr('width', '100%');
$('div.content img').attr('height', '100%');
How can i modify the img-s style attr with jquery, and set width and height to 100%?
Thank you!
Share Improve this question asked Jul 25, 2016 at 15:55 Takács ZoltánTakács Zoltán 1173 silver badges15 bronze badges 1-
2
By using
css()
, but is the question how to get ckeditor to do it? – epascarello Commented Jul 25, 2016 at 15:56
3 Answers
Reset to default 4You can just use jQuery
's CSS -
$('div.content img').css({
'width' : '100%',
'height' : '100%'
});
http://api.jquery./css/
If you need to set the style attributes, you can use jQuery's .css():
$('div.content img').css('width', '100%');
$('div.content img').css('height', '100%');
See https://api.jquery./css/
Have you tried something like this:
$("div.content img").css("cssText", "width: 100% !important;");>
Using jQuery to create the css and using !important to force it to take change
本文标签: javascriptSet image width and height with jqueryStack Overflow
版权声明:本文标题:javascript - Set image width and height with jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744299037a2599486.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论