gpt4 book ai didi

javascript - 使用 ExecCommand 插入多级无序列表

转载 作者:行者123 更新时间:2023-11-30 17:04:29 24 4
gpt4 key购买 nike

我有一个使用“execCommand”创建的 javascript 所见即所得编辑器,我想知道如何使用此命令创建多级项目符号列表。

目前我有一个按钮可以在编辑器上执行这段代码来创建一个无序列表:

所见即所得.document.execCommand('InsertUnorderedList',false,'NewUL');

我的问题是,如果我想通过按下按钮创建子级别的项目符号,javascript 显然只会关闭 UL。

关于如何创建子无序列表有什么想法吗?

最佳答案

一种简单的方法是在选择要更改的项目时使用 indentoutdent 命令:

WYSIWYG.document.execCommand('indent', false, null);

关于javascript - 使用 ExecCommand 插入多级无序列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28272928/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com