![](/img/trans.png)
[英]click a button to change text font-size of <body> in javascript/css
[英]TintMCE - Change text font size after button click
在單擊“ Change Font
的字體按鈕后,我想更改所選文本的大小:但是使用該行后,它沒有改變:
editor.execCommand("fontSize", false, e.data.source)
這是帶有小提琴的代碼:
<script type="text/javascript">
tinymce.init({
selector: "textarea",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
toolbar: "wrapselection | code | insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
setup: function (editor) {
editor.addButton('wrapselection', {
text: 'Change Font',
icon: false,
onclick: function () {
editor.windowManager.open({
title: 'Enter Font Size',
body: [
{type: 'textbox', name: 'source', label: 'Font Size'}
],
onsubmit: function(e) {
alert(e.data.source);
editor.focus();
editor.execCommand("fontSize", false, e.data.source);
}
});
}
});
}
});
</script>
<form method="post" action="dump.php">
<textarea name="content">This is content in the editor</textarea>
</form>
http://fiddle.tinymce.com/a7gaab
用戶單擊大小后如何更改字體大小?
只需在警報消息之后添加以下代碼行
editor.getBody().style.fontSize = e.data.source + 'px';
更新的代碼
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.