<!DOCTYPE html>
<html>
<head>
<title>字符串操作函数</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="http://www.imooc.com/data/jquery-1.8.2.min.js" type="text/javascript"></script>
</head>
<body>
<div id="divtest">
<div class="title">
<span class="fl">字符串操作函数</span>
<span class="fr">
<input id="btnShow" name="btnShow" type="button" value="计算" />
</span>
</div>
<div class="content">
<input id="txtName" name="txtName" type="text" />
<div class="tip"></div>
</div>
</div>
<script type="text/javascript">
$(function () {
$("#btnShow").bind("click", function () {
$(".tip").html("");
var strTmp = "内容:";
var strOld = $("#txtName").val();
var strNew =?;
strTmp += strOld;
strTmp += "<br/><br>除掉空格符前的长度:"
strTmp += strOld.length;
strTmp += "<br/><br>除掉空格符后的长度:"
strTmp += strNew.length;
$(".tip").show().append(strTmp);
});
});
</script>
</body>
</html>
#divtest
{
width: 282px;
}
#divtest .title
{
padding: 8px;
background-color: Blue;
color: #fff;
height: 23px;
line-height: 23px;
font-size: 15px;
font-weight: bold;
}
#divtest .content
{
padding: 8px;
background-color: #fff;
font-size: 13px;
}
#divtest .content .tip
{
border: solid 1px #ccc;
background-color: #eee;
margin: 20px 0px;
padding: 8px;
display: none;
}
.fl
{
float: left;
}
.fr
{
float: right;
}