HTML 对字体的样式的选择

来源:互联网 发布:判断字符串像素长度js 编辑:程序博客网 时间:2024/04/25 19:23
 <script type="text/javascript">        function SetToBold () {            var state = document.queryCommandState ("bold");            switch (state) {            case true:                alert ("The bold formatting will be removed from the selected text.");                break;            case false:                alert ("The selected text will be displayed in bold.");                break;            case null:                alert ("The state of the 'bold' command is indeterminable.");                break;            }            document.execCommand ('bold', true, null);        }    </script>


document 的execCommand 命令非常的强大,基本可以满足android,IOS端对HTML的一系列操作,例如,Bold,Underline,Italic 等等


document queryCommandState 可以查询某操作的状态,是否开启。

0 0