87,907
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
<!--
.textzone{
width:500px;
height:250px;
border:1px solid #CCCCCC;
}
-->
</style>
</head>
<body>
<textarea id="yuanma" class="textzone"></textarea>
<div id="shitu" contenteditable="true" class="textzone"></div>
</div>
<input type="button" value="Bold" id="bold1" />
<div id="bold2" style="border:1px solid #cccccc;width:50px;">Bold</div>
</body>
<script type="text/javascript">
<!--
function $(oid){
return document.getElementById(oid);
}
var o=document.getElementById("bold1");
o.onclick=function(){
document.execCommand("bold",false,"");
$("yuanma").value=$("shitu").innerHTML;
}
var obj=document.getElementById("bold2");
obj.onclick=function(){
document.execCommand("bold",false,"");
$("yuanma").value=$("shitu").innerHTML;
}
//-->
</script>
</html>