(097)jquery_工具函数_trim
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>util_trim.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <style type="text/css"> #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; } </style> <script type="text/javascript" src="../js/jquery/jquery-1.8.3.min.js"></script> <script type="text/javascript"> $(function(){ $("#btnShow").bind("click",function(){ var strOld = $("#txtName").val(); var strNew = $.trim(strOld); var strOldLength = strOld.length; var strNewLength = strNew.length; var str = "</br>"; str += strOld; str += ("</br>字符串处理之前长度为:" + strOldLength + "</br>"); str += strNew; str += ("</br>字符串处理之后长度为:" + strNewLength + "</br>"); $(".content").append(str); }); }); </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> </body> </html>
***万事万物都有裂痕,那是光照进来的地方***

浙公网安备 33010602011771号