js匯入的注意.txt

來源:互聯網
上載者:User

標籤:os   io   使用   java   ar   for   檔案   cti   sp   

如有兩個外部js檔案:
jquery-1.8.2.min.js Jqery的系統檔案
LYFArray.js 和個人的

===============我要將兩個js檔案匯入一個頁面的方法:=============================
<script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
//可使用jquery-1.4.1.min.js中的方法
var arrayInt = new Array();
function FunAddQusetion(qid) {
arrayInt.push(qid); //push()是系統方法
alert("添加後:"+arrayInt.toString());

}
</script>
----------------
<script src="../js/LYFArray.js" type="text/javascript"></script>
<script type="text/javascript">
//可使用LYFArray.js中方法
function FunsubQusetion(qid) {
arrayInt = arrayInt.delByValue(qid); //上面定義的數組也可用,delByValue()是自訂方法
alert("刪除後 數組=" + arrayInt.toString());

}
</script>

===============================================================================
===LYFArray.js檔案內容=========================================================

//定義自己的數組元素刪除方法,根據下標刪除
Array.prototype.delByIndex = function (n) {//n表示第幾項,從0開始算起。
//prototype為對象原型,注意這裡為對象增加自訂方法的方法。
if (n < 0)//如果n<0,則不進行任何操作。
return this;
else
return this.slice(0, n).concat(this.slice(n + 1, this.length));
/*
   concat方法:返回一個新數組,這個新數組是由兩個或更多數組組合而成的。
         這裡就是返回this.slice(0,n)/this.slice(n+1,this.length)
         組成的新數組,這中間,剛好少了第n項。
   slice方法: 返回一個數組的一段,兩個參數,分別指定開始和結束的位置。
  */
}


//定義自己的數組元素刪除方法,根據值刪除
Array.prototype.delByValue = function (valu) {
var inde = 0;
for (j = 0; j < this.length; j++) {
if (this[j] == valu) {
inde = j;
//alert("第" + j + " 的內容 " + this[j]);
}
}
//alert(" inde=" + inde);
if (inde < 0)//如果n<0,則不進行任何操作。
return this;
else
return this.slice(0, inde).concat(this.slice(inde + 1, this.length));
}

===============================================================================

 

js匯入的注意.txt

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.