jQuery中$.extend()用法執行個體,jquery.extend

來源:互聯網
上載者:User

jQuery中$.extend()用法執行個體,jquery.extend

本文執行個體講述了jQuery中$.extend()用法。分享給大家供大家參考。具體分析如下:

$.extend()方法定義如下:

jQuery.extend([deep], target, object1, [objectN])

用一個或多個其他對象來擴充一個對象,返回被擴充的對象。
如果不指定target,則給jQuery命名空間本身進行擴充。這有助於外掛程式作者為jQuery增加新方法。 如果第一個參數設定為true,則jQuery返回一個深層次的副本,遞迴地複製找到的任何對象。否則的話,副本會與原對象共用結構。 未定義的屬性將不會被複製,然而從對象的原型繼承的屬性將會被複製。

看下面的代碼就知道怎麼用了,請看:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>extendFun</title><script src="../scripts/jquery-1.9.0.js" type="text/javascript"></script><meta name="author" content="Administrator" /><!-- Date: 2013-01-30 --><script type="text/javascript">$(function () {var pageConfig= {};var pageConfig=$.extend(pageConfig,{createUrl: '${ROOT}/subject/createOrModifyPageTemplates',deleteUrl: '${ROOT}/subject/deletePageTemplates',modifyUrl: '${ROOT}/subject/createOrModifyPageTemplates',infoName: 'pageTemplateInfo'});$("#subm").click(function(){var posturl= pageConfig.deleteUrl;alert(posturl);});})</script></head><body><input id="subm" name="subm" type="button" value="clickme" ></body></html>

輸出結果:${ROOT}/subject/deletePageTemplates

希望本文所述對大家的jQuery程式設計有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.