JavaScriptº¯Êý¶¨ÒåÓï·¨×ܽá
JavaScript
º¯Êý¶¨ÒåÓï·¨×ܽá
×÷Õß
»Æ³Ï
QQ
Ⱥ£º
65643887
1
£®Õý³£µÄ¶¨Òå·½·¨£º
function functionName([arguments]){
Javascript statements
[return expression]
}
Àý
1:
function evalScript( i, elem ) {
if ( elem.src )
jQuery.ajax({
url:
elem.src,
async:
false,
dataType:
"script"
});
else
jQuery.globalEval(
elem.text || elem.textContent || elem.innerHTML || "" );
if ( elem.parentNode )
elem.parentNode.removeChild(
elem );
}
2.
ÄäÃûº¯Êý
ÉÏÃæµÄÆäÖеÄ
functionName
¿É
ÒÔÊ¡ÂÔ£¬³ÉΪÄäÃûº¯Êý£º
var func2 = function(…){…};
Àý
1
£º
var max = function(a, b){
if(a>b) return a;
return b;
}
Àý
2
£º
dojo.isString = function(/*anything*/ it){
//summary:
//Return true if it is a String
return !!arguments.length &&
it != null && (typeof it == &
Ïà¹ØÎĵµ£º
Õâ¾ä»°ÊÇ£ºprototypeÖж¨ÒåµÄÊǶÔÏóʵÀýÒª·ÃÎʵÄÊôÐÔ»ò·½·¨µÄÒ»¸öÌæ²¹¡£
¾ÙÀý˵Ã÷һϣº
//1£©¶¨ÒåÁËÒ»¸ö¶ÔÏó£º
function A()
{
//¸ø¶ÔÏó¶¨ÒåÒ»¸öÊôÐÔ
this.f1="this is f1";
}
//2£©ÎÒÃÇ¿ÉÒÔÕâÑùʹÓöÔÏó£º
var a = new A();
alert(a.f1)//µ¯³öÏûÏ¢£ºthis is f1
//3£©ÎÒÃÇ¿ÉÒÔÀ©Õ¹¶ÔÏó£º
A.prot ......
ת×Ô£ºhttp://www.felixwoo.com/?s=%E9%97%AD%E5%8C%85
ÉîÈëÀí½âJavaScript±Õ°ü(closure)
·¢±íÓÚ: 14:48 | ·ÖÀà: ¿ª·¢¼¼Êõ | ÆÀÂÛ: 25 | ÈËÆø: 6,114 |
×î½üÔÚÍøÉϲéÔÄÁ˲»ÉÙJavascript±Õ°ü(closure)Ïà¹ØµÄ×ÊÁÏ£¬Ð´µÄ´ó¶àÊǷdz£µÄѧÊõºÍרҵ¡£¶ÔÓÚ³õѧÕßÀ´Ëµ±ð˵Àí½â±Õ°üÁË£¬¾ÍÁ¬ÎÄ×ÖÐðÊö¶¼ºÜÄÑ¿´¶®¡£×«Ð´´ËÎĵÄÄ¿µÄ¾ ......
±¾ÎÄÖ÷Òª½éÉÜÈçºÎ¶¯Ì¬µÄÔö¼Ó¡¢É¾³ýÊäÈë¿ò£¬²¢»ñÈ¡ÊäÈë¿òÖеÄÖµ~~
<html>
<head>
<title>JavaScript_¶¯Ì¬Ôö¼Ó/ɾ³ýÊäÈë¿ò_°¢·½Ë÷</title>
<script type="text/javascript">
<!--
var idNumber = 1,id="tableAFS";
function addTextBox() {
idNumber++;
//ÕâÀïÎÒÃÇ´´½¨Ò»¸ölab ......
±¾ÎĽ«½éÉܼ¸¸ö³£ÓõÄJavaScriptÑéÖ¤ÕýÔò±í´ïʽ£¬ÕâЩ×ÊÁÏÏ£Íû¶Ô´ó¼ÒÔÚʵ¼Ê±à³Ì¹ý³ÌÖÐÆðµ½°ïÖú×÷Óá£
Æ¥ÅäÖÐÎÄ×Ö·ûµÄÕýÔò±í´ïʽ£º [u4e00-u9fa5]
ÆÀ×¢£ºÆ¥ÅäÖÐÎÄ»¹ÕæÊǸöÍ·ÌÛµÄÊ£¬ÓÐÁËÕâ¸ö±í´ïʽ¾ÍºÃ°ìÁË
Æ¥ÅäË«×Ö½Ú×Ö·û(°üÀ¨ºº×ÖÔÚÄÚ)£º[^x00-xff]
ÆÀ×¢£º¿ÉÒÔÓÃÀ´¼ÆËã×Ö·û´®µÄ³¤¶È£¨Ò»¸öË«×Ö½Ú×Ö·û³¤¶È¼Æ2£¬ASCII×Ö·û ......
JavaScript replace() ·½·¨
JavaScript String ¶ÔÏó²Î¿¼ÊÖ²á
¶¨ÒåºÍÓ÷¨
replace() ·½·¨ÓÃÓÚÔÚ×Ö·û´®ÖÐÓÃһЩ×Ö·ûÌæ»»ÁíһЩ×Ö·û£¬»òÌæ»»Ò»¸öÓëÕýÔò±í´ïʽƥÅäµÄ×Ó´®¡£
Óï·¨
stringObject.replace(regexp,replacement)
²ÎÊýÃèÊö
regexp
±ØÐè¡£¹æ¶¨ÁËÒªÌæ»»µÄģʽµÄ RegExp ¶ÔÏó¡£Çë×¢Ò⣬Èç¹û¸ÃÖµÊÇÒ»¸ö×Ö·û´®£¬Ôò½ ......