当我按下粗体按钮时,我希望能够在文本区域中加粗文本。但是,当我按下粗体按钮时,文本根本不会改变。此外,我希望在加粗文本后文本仍然突出显示。我该怎么办?
HTML代码:
<div class="col-md-8">
<input type = "button" value = "B" onclick = "bold()">
<input type = "button" value = "I" onclick = "italics()">
<input type = "button" value = "U" onclick = "underline()">
<input type = "button" value = "Size" onclick = "fontsize()">
<input type = "button" value = "Color" onclick = "fontcolor()">
<input type = "button" value = "Highlight" onclick = "highlight()">
<input type = "button" value = "Link" onclick = "link()">
<input type = "button" value = "Strike" onclick = "strikethrough()">
<input type = "button" value = "Exp" onclick = "exponent()">
<input type = "button" value = "Sub" onclick = "subscript()">
<input type = "button" value = "Bullet" onclick = "bullet()">
<input type = "button" value = "List" onclick = "list()">
<input type = "button" value = "Space" onclick = "spacing()">
<br><br>
<textarea name = "content" id = "content" style = "width: 720; height: 400;" ></textarea>
Javascript代码:
function bold(){
content.document.execCommand('bold', false, null);
}