Ôö¼Ó 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>
Ïà¹ØÎĵµ£º
µÚ¶þÕ Data Access Êý¾Ý·ÃÎÊ
One of the classic computer science problems is determining where data should be stored for optimal reading and writing. Where data is stored is related to how quickly it can be retrieved during code execution. This problem in JavaScri ......
ȺÀïÌÖÂÛ¹ýµÄÌâÄ¿£¬·ÖÏíһϡ£
function test(){
var m=n=1;
alert(m);
}
alert(n);
//ÒòΪtestº¯ÊýûÓÐÖ´ÐУ¬³Ì¶È¿ØÖÆÁ÷²»ÄܽøÈë½øÐнâÎö£¬ÀïÃæµÄ¶«Î÷¶ÔÍâÃæ²»¿É¼û£¬Òò´Ë±¨´í
function test(){
var m=n=1;
alert(m);
}
test();
alert(n);
//µ±testÖ´Ðкó£¬Í ......
ÇëÏÈ¿´ÏÂÌ⣺
if(true)
{
a = 1;
}
alert(a); //Êä³öɶ£¿
if(true)
{
var a = 1;
}
alert(a); //ÕâÓÖÊä³öʲô£¿
ÔÚfirefox3.5Ï£¬µÚÒ»¸öÊä³ö1;µÚ¶þ¸öÊä³öundefined£¡£¡£¡
ÎªÉ¶ÄØ£¿ºÇºÇ£¬±¾ÈËÔڴ˰àÃÅŪ¸«Ò»Ï£º
Ò»°ãÇé¿öÏÂȱʡvarÉùÃ÷ʱ£¬Ä¬È ......
È¡Ç°ÃæÁ½ÖÖµÄÓŵ㣺
a¡¢Óù¹Ô캯ÊýÀ´¶¨ÒåÀàÊôÐÔ£¨×ֶΣ©
b¡¢ÓÃÔÐÍ·½Ê½À´¶¨ÒåÀàµÄ·½·¨¡£
¾ÍÓÐÁ˵ÚÈýÖÖ·½Ê½¡£ÕâÖÖ·½Ê½Ã²ËƲÉÓõÄÈ˽϶ࡣ
3¡¢×ۺϹ¹Ô캯Êý/ÔÐÍ
/**
* PersonÀࣺ¶¨ÒåÒ»¸öÈË£¬ÓиöÊôÐÔname£¬ºÍÒ»¸ögetName·½·¨
* @param {String} name
*/
function Person(name) {
this.name = name;
}
Pers ......
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 ......