我们如何在CKEditor实例中调用javascript函数?

时间:2016-10-05 08:23:13

标签: javascript ckeditor

<script type="text/javascript">
        $(document).ready(function () {
            var editor = CKEDITOR.replace('CKEditor1');
            var ckeditor = CKEDITOR.instances['CKEditor1'];
            ckeditor.on('key', function (event) {
                var x = event.data.keyCode;
                console.log(x);
                if (x == 13) {                  
                   Capitalize();
                }
                else if (x == 32) {
                   alert("Press enter!!!!");
                }
                function Capitalize() {
                    if (this.value.match(/^[a-z]/)) {
                        this.value = this.value.replace(/^./, function (letter) {
                            return letter.toUpperCase();
                        });
                    }
                }
            });
        });

按Enter键或空格键后,我想自动将首字母大写。我只是想在用户按下特定键时激活我的功能。

0 个答案:

没有答案