Ôö¼Ó javascript µÄ trim º¯Êý
È¥³ý×Ö·û´®×óÓÒÁ½¶ËµÄ¿Õ¸ñ£¬ÔÚvbscriptÀïÃæ¿ÉÒÔÇáËɵØʹÓà trim¡¢ltrim »ò rtrim£¬µ«ÔÚjsÖÐȴûÓÐÕâ3¸öÄÚÖ÷½·¨£¬ÐèÒªÊÖ¹¤±àд¡£ÏÂÃæµÄʵÏÖ·½·¨ÊÇÓõ½ÁËÕýÔò±í´ïʽ£¬Ð§Âʲ»´í£¬²¢°ÑÕâÈý¸ö·½·¨¼ÓÈëString¶ÔÏóµÄÄÚÖ÷½·¨ÖÐÈ¥¡£
<input type="text" name="mytxt" value=" 12345678 " /><br>
<input type="button" name="cmd1" onclick="mytxt2.value=mytxt.value.trim()" value="È¥Á½±ßµÄ¿Õ¸ñ"/>
<input type="text" name="mytxt2"/><br>
<input type="button" name="cmd1" onclick="mytxt3.value=mytxt.value.ltrim()" value="È¥×ó±ßµÄ¿Õ¸ñ"/>
<input type="text" name="mytxt3"/><br>
<input type="button" name="cmd1" onclick="mytxt4.value=mytxt.value.rtrim()" value="È¥ÓұߵĿոñ"/>
<input type="text" name="mytxt4"/><br>
<script language="javascript">
String.prototype.trim=function(){
return this.replace(/(^s*)|(s*$)/g, "");
}
String.prototype.ltrim=function(){
return this.replace(/(^s*)/g,"");
}
String.prototype.rtrim=function(){
return this.replace(/(s*$)/g,"");
}
</script>
д³Éº¯Êý¿ÉÒÔÕâÑù£º
<script type="text/javascript">
function trim(str){ //ɾ³ý×óÓÒÁ½¶ËµÄ¿Õ¸ñ
return str.replace(/(^s*)|(s*$)/g, "");
}
function ltrim(str){ //ɾ³ý×ó±ßµÄ¿Õ¸ñ
return str.replace(/(^s*)/g,"");
}
function rtrim(str){ //ɾ³ýÓұߵĿոñ
return str.replace(/(s*$)/g,"");
}
</script>
Ïà¹ØÎĵµ£º
ÔÚjavascriptº¯ÊýÌåÄÚ£¬±êʶ·ûarguments¾ßÓÐÌØÊ⺬Òå¡£ËüÊǵ÷ÓöÔÏóµÄÒ»¸öÌØÊâÊôÐÔ£¬ÓÃÀ´ÒýÓÃArguments¶ÔÏó¡£Arugments¶ÔÏó¾ÍÏñÊý×飬עÒâÕâÀïÖ»ÊÇÏñ²¢²»Êǹþ¡£
javascriptº¯ÊýÌåÄÚ£¬argumentsÏñÊý×é(²¢²»ÊÇÕæµÄÊý×飬ÊÇÒ»¸öArguments¶ÔÏó£¬ÔÙ´ÎÇ¿µ÷)Ò»Ñù£¬ÓÐlengthÊôÐÔ£¬¿ÉÒÔ´ú±í´«¸øº¯ÊýµÄ²ÎÊýµÄ¸öÊý¡£
ÒýÓÃÒ»¸öÐÎʽ²ÎÊ ......
ÓÐЩÍøÓѾ³£Ñ¯ÎÊ£ºÔÚVC++ÖÐÈçºÎ·ÃÎÊjavascriptÖеĶÔÏ󡢺¯Êý¡¢±äÁ¿µÈÔªËØ£¿
ÕâÀï°ÑÒÔÇ°·¢±íµÄһϵÁÐÎÄÕ¼¯ÖÐÔÚÒ»Æ𣬷½±ã²éÔÄ¡£
vc++·ÃÎÊjavascript(1)--windowÔڽű¾ÒýÇæÖеÄ×÷ÓÃ
http://blog.csdn.net/pimshell/archive/2008/08/02/2758863.aspx
vc++·ÃÎÊjavascript(2)--IDispatchExÊǶ¯Ì¬½Å±¾ÓïÑԵĻù´¡&nb ......
Introduction
This article is about passing data between VB.NET/C# WinForms and JavaScript.
Before reading further, let me warn you that this article is not about ASP.NET. Concepts covered in the article are applied to Desktop applications.
Background
I was working on a project which required dat ......
AS("#...").keypress(function(event) {
if (navigator.userAgent.toLowerCase().indexOf("mozilla") >= 0) {
var $key = event.charCode ;
} else {
var $key = event. ......