className用法
4.className用法
例 4.1(keyIEFF.html)
<!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"/>
<title>
</title>
<script language="JavaScript" type="text/javascript">
function calc(thistextar, Span) {
var len = thistextar.value.length;
Span.innerHTML = len + ' 字';
Span.className = 'toredC';
}
</script>
<style type="text/css">
<!--
.toredC {
color: #FF0000;
}
-->
</style>
</head>
<body><textarea cols="50" rows="3" onKeyUp="calc(this,document.getElementById('num'))"
></textarea>
(<SPAN id=num>字数</SPAN>)
</body>
</html>
更多内容请见原文,文章转载自:https://blog.csdn.net/qq_43650923/article/details/102822703