这是特定的 html 代码,由“粗体”按钮和文本区域组成。
<form name="myform">
< input type="button" onClick="Bold()" value="Bold">
</form>
<textarea name="myTextArea" id="myTextArea" cols="100" rows="14" placeholder="Enter Text Here ...">< /textarea>
这是我的 JavaScript
function Bold() {
myTextArea.document.execCommand('bold',false,null);
}
我做错了什么???
最佳答案
你可以像这样简单地使用 JavaScript:
function Bold() {
document.getElementById("myTextArea").style.fontWeight = 'bold';
}
关于javascript - 将文本区域中的文本设置为粗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22068242/