【发布时间】:2014-03-26 21:15:49
【问题描述】:
我正在尝试制作一个文本区域,我可以在其中将里面的文本更改为粗体、斜体、下划线等... 到目前为止,这是我的代码:
<body>
<form name="form1" action="" method="">
<div id="theForm">
<br><br>
<textarea id="theText" cols="40" rows="5" name="">
</textarea>
<br><br>
</div>
</form>
<button form="theForm" onclick="boldText()" type="button">Bold</button>
<button form="theForm" onclick="italicText()" type="button">Italic</button>
<button form="theForm" onclick="underlineText()" type="button">Underline</button>
</body>
</html>
<style>
#theForm
{
text-align:center;
position:absolute;
top:10%;
left:40%;
}
</style>
<script>
function boldtext() {
theText.style.fontWeight = 'bold';
}
</script>
我什至不确定如何启动 Javascript 代码.. 任何帮助将不胜感激!
【问题讨论】:
标签: javascript text attributes formatting textarea