按钮和div都有相同的'onclick'代码,但execCommand似乎只对按钮有效.按下div时,有什么方法可以使它工作吗?
这是我的小提琴:http: //jsfiddle.net/foreyez/ZzL8y/
<button onclick="document.execCommand('bold',false,null);">Bold</button>
<div onclick="document.execCommand('bold',false,null);" style='border:1px solid black;width:50px;'>Bold</div>
<div id='input' contenteditable='true'>
select some of this text and then hit one of the buttons above
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8678 次 |
| 最近记录: |